From 4fffe4a964238956024255a2e28a29f736d23b9d Mon Sep 17 00:00:00 2001 From: Dan Palmer Date: Tue, 10 Sep 2019 15:05:27 +0100 Subject: [PATCH 01/20] Move to namespaced template directory This prevents us from colliding with templates in other apps, and makes it clearer how templates can be overridden. --- response/templates/{ => response}/base.html | 0 response/templates/{ => response}/incident_doc.html | 2 +- response/ui/views.py | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) rename response/templates/{ => response}/base.html (100%) rename response/templates/{ => response}/incident_doc.html (98%) diff --git a/response/templates/base.html b/response/templates/response/base.html similarity index 100% rename from response/templates/base.html rename to response/templates/response/base.html diff --git a/response/templates/incident_doc.html b/response/templates/response/incident_doc.html similarity index 98% rename from response/templates/incident_doc.html rename to response/templates/response/incident_doc.html index 6017bb18..11504905 100644 --- a/response/templates/incident_doc.html +++ b/response/templates/response/incident_doc.html @@ -1,4 +1,4 @@ -{% extends "base.html" %} +{% extends "response/base.html" %} {% load static %} {% load unslackify %} {% load markdown_filter %} diff --git a/response/ui/views.py b/response/ui/views.py index 03281f6c..f59f7796 100644 --- a/response/ui/views.py +++ b/response/ui/views.py @@ -26,7 +26,7 @@ def incident_doc(request: HttpRequest, incident_id: str): ] return render( request, - template_name="incident_doc.html", + template_name="response/incident_doc.html", context={ "incident": incident, "events": events, From 751063ac0bf2248288e351bb77bc45ee3383f24d Mon Sep 17 00:00:00 2001 From: Dan Palmer Date: Tue, 10 Sep 2019 15:25:43 +0100 Subject: [PATCH 02/20] Remove commented code --- response/templates/response/base.html | 1 - 1 file changed, 1 deletion(-) diff --git a/response/templates/response/base.html b/response/templates/response/base.html index 15a3b4fb..de427d4b 100644 --- a/response/templates/response/base.html +++ b/response/templates/response/base.html @@ -50,7 +50,6 @@ - {% comment %} {% endcomment %} {% block javascript %}{% endblock %} From cc554419bc5ed859e5de2ec9d6300b688c3197f1 Mon Sep 17 00:00:00 2001 From: Dan Palmer Date: Tue, 10 Sep 2019 15:26:58 +0100 Subject: [PATCH 03/20] More consistent whitespace/indentation --- response/templates/response/incident_doc.html | 106 +++++++++--------- 1 file changed, 53 insertions(+), 53 deletions(-) diff --git a/response/templates/response/incident_doc.html b/response/templates/response/incident_doc.html index 11504905..1d7e2aa4 100644 --- a/response/templates/response/incident_doc.html +++ b/response/templates/response/incident_doc.html @@ -1,79 +1,79 @@ {% extends "response/base.html" %} + {% load static %} {% load unslackify %} {% load markdown_filter %} {% block head %} - + {% endblock %} - {% block content %} -
+
- {% comment %} ----- Heading ----- {% endcomment %} -

Incident {{ incident.pk }}

-
{{ incident.status_text|upper }} - {% if incident.severity_text %}- {{ incident.severity_text|upper}} SEVERITY{% endif %}
+ {% comment %} ----- Heading ----- {% endcomment %} +

Incident {{ incident.pk }}

+
{{ incident.status_text|upper }} + {% if incident.severity_text %}- {{ incident.severity_text|upper}} SEVERITY{% endif %}
- {% comment %} ----- Summary ----- {% endcomment %} -

Summary

-

{% if incident.summary %}{{ incident.summary|unslackify|markdown_filter|safe }}{% endif %}

-
    - {% if incident.impact %}
  • Impact:{{ incident.impact|unslackify|markdown_filter|safe }}
  • {% endif %} -
  • Reporter:{{ incident.reporter.display_name }}
  • - {% if incident.lead %}
  • Lead:{{ incident.lead.display_name }}
  • {% endif %} + {% comment %} ----- Summary ----- {% endcomment %} +

    Summary

    +

    {% if incident.summary %}{{ incident.summary|unslackify|markdown_filter|safe }}{% endif %}

    +
      + {% if incident.impact %}
    • Impact:{{ incident.impact|unslackify|markdown_filter|safe }}
    • {% endif %} +
    • Reporter:{{ incident.reporter.display_name }}
    • + {% if incident.lead %}
    • Lead:{{ incident.lead.display_name }}
    • {% endif %} -
    • Start Time:{% if incident.start_time %}{{ incident.start_time }}{% endif %}
    • -
    • Report Time:{% if incident.report_time %}{{ incident.report_time }}{% endif %}
    • +
    • Start Time:{% if incident.start_time %}{{ incident.start_time }}{% endif %}
    • +
    • Report Time:{% if incident.report_time %}{{ incident.report_time }}{% endif %}
    • - {% if incident.is_closed %} -
    • End Time:{{ incident.end_time }}
    • -
    • Duration:{{ incident.duration}}
    • - {% endif %} + {% if incident.is_closed %} +
    • End Time:{{ incident.end_time }}
    • +
    • Duration:{{ incident.duration}}
    • + {% endif %} - {% if user_stats %} -
    • Participants: -
        - {% for stats in user_stats %} -
      • - {{ stats.user.display_name }} ({{stats.message_count}} messages) -
      • - {% endfor %} -
      + {% if user_stats %} +
    • Participants: +
        + {% for stats in user_stats %} +
      • + {{ stats.user.display_name }} ({{stats.message_count}} messages)
      • - {% endif %} - -
      - {% comment %} ----- Actions ----- {% endcomment %} -

      Actions

      - {% if actions %} -
        - {% for action in actions.all %} -
      • {{ action.details|unslackify|markdown_filter|safe }}
      • - {% endfor %} -
      + {% endfor %} +
    + {% endif %} - {% comment %} ----- Timeline ----- {% endcomment %} -

    Timeline

    - {% if incident.timeline_events %} +
+ + {% comment %} ----- Actions ----- {% endcomment %} +

Actions

+ {% if actions %} +
    + {% for action in actions.all %} +
  • {{ action.details|unslackify|markdown_filter|safe }}
  • + {% endfor %} +
+ {% endif %} + + {% comment %} ----- Timeline ----- {% endcomment %} +

Timeline

+ {% if events %}
- {% for event in incident.timeline_events.all %} -
-
- {{ event.timestamp|date:"H:i:s" }} - {{ event.text|stringformat:'s'|unslackify|markdown_filter|safe }} -
+ {% for event in events.all %} +
+
+ {{ event.icon|safe }}{{ event.timestamp|date:"H:i:s" }} + {{ event|stringformat:'s'|unslackify|markdown_filter|safe }}
- {% endfor %} +
+ {% endfor %}
- {% endif %} - + {% endif %}
-
+
{% endblock %} From c79a20d1af1c93476906a7a9f5a40b18782d33a2 Mon Sep 17 00:00:00 2001 From: Dan Palmer Date: Sat, 14 Sep 2019 15:13:21 +0100 Subject: [PATCH 04/20] Link to the root of the site This is general good practice and expected UX for navbars --- response/templates/response/base.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/response/templates/response/base.html b/response/templates/response/base.html index de427d4b..5c0fbb96 100644 --- a/response/templates/response/base.html +++ b/response/templates/response/base.html @@ -27,7 +27,7 @@ + + {% block messages %} +
+
+ {% for message in messages %} +
+ {{ message }} +
+ {% endfor %} +
+
+ {% endblock %} +
{% block content %}{% endblock %} diff --git a/response/templatetags/bootstrap4_alerts.py b/response/templatetags/bootstrap4_alerts.py new file mode 100644 index 00000000..827e7e19 --- /dev/null +++ b/response/templatetags/bootstrap4_alerts.py @@ -0,0 +1,10 @@ +from django import template + +register = template.Library() + + +@register.filter +def bootstrap4_alert_class(message): + if message.tags == "error": + return "alert-danger" + return f"alert-{message.tags}" From 70b42822542639308c500c1bc23d571a4403c131 Mon Sep 17 00:00:00 2001 From: Dan Palmer Date: Sat, 14 Sep 2019 15:25:00 +0100 Subject: [PATCH 06/20] Tune up layout This moves the background colour down the DOM a little to align margins/layout more consistently, and tweaks margins/padding to be more consistent. It looks slightly more consistent, and by not including bg-white at the base template level we make it more re-usable. --- response/templates/response/base.html | 2 +- response/templates/response/incident_doc.html | 101 +++++++++--------- 2 files changed, 53 insertions(+), 50 deletions(-) diff --git a/response/templates/response/base.html b/response/templates/response/base.html index 6a640580..98db1c4b 100644 --- a/response/templates/response/base.html +++ b/response/templates/response/base.html @@ -59,7 +59,7 @@ {% endblock %} -
+
{% block content %}{% endblock %}
diff --git a/response/templates/response/incident_doc.html b/response/templates/response/incident_doc.html index 1d7e2aa4..22a4246b 100644 --- a/response/templates/response/incident_doc.html +++ b/response/templates/response/incident_doc.html @@ -9,71 +9,74 @@ {% endblock %} {% block content %} -
+
+
{% comment %} ----- Heading ----- {% endcomment %} -

Incident {{ incident.pk }}

+

Incident {{ incident.pk }}

{{ incident.status_text|upper }} {% if incident.severity_text %}- {{ incident.severity_text|upper}} SEVERITY{% endif %}
+
+
+ {% comment %} ----- Summary ----- {% endcomment %} +

Summary

+

{% if incident.summary %}{{ incident.summary|unslackify|markdown_filter|safe }}{% endif %}

+
    + {% if incident.impact %}
  • Impact:{{ incident.impact|unslackify|markdown_filter|safe }}
  • {% endif %} +
  • Reporter:{{ incident.reporter.display_name }}
  • + {% if incident.lead %}
  • Lead:{{ incident.lead.display_name }}
  • {% endif %} - {% comment %} ----- Summary ----- {% endcomment %} -

    Summary

    -

    {% if incident.summary %}{{ incident.summary|unslackify|markdown_filter|safe }}{% endif %}

    -
      - {% if incident.impact %}
    • Impact:{{ incident.impact|unslackify|markdown_filter|safe }}
    • {% endif %} -
    • Reporter:{{ incident.reporter.display_name }}
    • - {% if incident.lead %}
    • Lead:{{ incident.lead.display_name }}
    • {% endif %} +
    • Start Time:{% if incident.start_time %}{{ incident.start_time }}{% endif %}
    • +
    • Report Time:{% if incident.report_time %}{{ incident.report_time }}{% endif %}
    • -
    • Start Time:{% if incident.start_time %}{{ incident.start_time }}{% endif %}
    • -
    • Report Time:{% if incident.report_time %}{{ incident.report_time }}{% endif %}
    • + {% if incident.is_closed %} +
    • End Time:{{ incident.end_time }}
    • +
    • Duration:{{ incident.duration}}
    • + {% endif %} - {% if incident.is_closed %} -
    • End Time:{{ incident.end_time }}
    • -
    • Duration:{{ incident.duration}}
    • - {% endif %} - - {% if user_stats %} -
    • Participants: -
        - {% for stats in user_stats %} -
      • - {{ stats.user.display_name }} ({{stats.message_count}} messages) -
      • - {% endfor %} -
      -
    • - {% endif %} + {% if user_stats %} +
    • Participants: +
        + {% for stats in user_stats %} +
      • + {{ stats.user.display_name }} ({{stats.message_count}} messages) +
      • + {% endfor %} +
      +
    • + {% endif %} -
    +
- {% comment %} ----- Actions ----- {% endcomment %} -

Actions

- {% if actions %} -
    - {% for action in actions.all %} -
  • {{ action.details|unslackify|markdown_filter|safe }}
  • - {% endfor %} -
- {% endif %} + {% comment %} ----- Actions ----- {% endcomment %} +

Actions

+ {% if actions %} +
    + {% for action in actions.all %} +
  • {{ action.details|unslackify|markdown_filter|safe }}
  • + {% endfor %} +
+ {% endif %} - {% comment %} ----- Timeline ----- {% endcomment %} -

Timeline

- {% if events %} -
- {% for event in events.all %} -
-
- {{ event.icon|safe }}{{ event.timestamp|date:"H:i:s" }} - {{ event|stringformat:'s'|unslackify|markdown_filter|safe }} + {% comment %} ----- Timeline ----- {% endcomment %} +

Timeline

+ {% if events %} +
+ {% for event in events.all %} +
+
+ {{ event.icon|safe }}{{ event.timestamp|date:"H:i:s" }} + {{ event|stringformat:'s'|unslackify|markdown_filter|safe }} +
+ {% endfor %}
- {% endfor %} -
- {% endif %} + {% endif %} +
{% endblock %} From 3bfc3c411eac80c148b22aad7d01fe8d547a963c Mon Sep 17 00:00:00 2001 From: Dan Palmer Date: Sat, 14 Sep 2019 15:28:45 +0100 Subject: [PATCH 07/20] Reflow for readability, no functional changes --- response/templates/response/incident_doc.html | 78 +++++++++++++------ 1 file changed, 56 insertions(+), 22 deletions(-) diff --git a/response/templates/response/incident_doc.html b/response/templates/response/incident_doc.html index 22a4246b..260db43b 100644 --- a/response/templates/response/incident_doc.html +++ b/response/templates/response/incident_doc.html @@ -5,7 +5,7 @@ {% load markdown_filter %} {% block head %} - + {% endblock %} {% block content %} @@ -13,25 +13,56 @@
- {% comment %} ----- Heading ----- {% endcomment %} -

Incident {{ incident.pk }}

-
{{ incident.status_text|upper }} - {% if incident.severity_text %}- {{ incident.severity_text|upper}} SEVERITY{% endif %}
+ + {% comment %} ----- Heading ----- {% endcomment %} +

+ Incident {{ incident.pk }} +

+ +
+ + {{ incident.status_text|upper }} + + {% if incident.severity_text %} + - {{ incident.severity_text|upper}} SEVERITY + {% endif %} +
+
+ {% comment %} ----- Summary ----- {% endcomment %}

Summary

-

{% if incident.summary %}{{ incident.summary|unslackify|markdown_filter|safe }}{% endif %}

+

+ {% if incident.summary %} + {{ incident.summary|unslackify|markdown_filter|safe }} + {% endif %} +

+
    - {% if incident.impact %}
  • Impact:{{ incident.impact|unslackify|markdown_filter|safe }}
  • {% endif %} + {% if incident.impact %} +
  • + Impact:{{ incident.impact|unslackify|markdown_filter|safe }} +
  • + {% endif %} +
  • Reporter:{{ incident.reporter.display_name }}
  • - {% if incident.lead %}
  • Lead:{{ incident.lead.display_name }}
  • {% endif %} -
  • Start Time:{% if incident.start_time %}{{ incident.start_time }}{% endif %}
  • -
  • Report Time:{% if incident.report_time %}{{ incident.report_time }}{% endif %}
  • + {% if incident.lead %} +
  • Lead:{{ incident.lead.display_name }}
  • + {% endif %} + +
  • + Start Time: + {% if incident.start_time %}{{ incident.start_time }}{% endif %} +
  • +
  • + Report Time: + {% if incident.report_time %}{{ incident.report_time }}{% endif %} +
  • {% if incident.is_closed %}
  • End Time:{{ incident.end_time }}
  • @@ -39,7 +70,8 @@

    Summary

    {% endif %} {% if user_stats %} -
  • Participants: +
  • + Participants:
      {% for stats in user_stats %}
    • @@ -49,17 +81,16 @@

      Summary

  • {% endif %} -
{% comment %} ----- Actions ----- {% endcomment %}

Actions

{% if actions %} -
    - {% for action in actions.all %} -
  • {{ action.details|unslackify|markdown_filter|safe }}
  • - {% endfor %} -
+
    + {% for action in actions.all %} +
  • {{ action.details|unslackify|markdown_filter|safe }}
  • + {% endfor %} +
{% endif %} {% comment %} ----- Timeline ----- {% endcomment %} @@ -67,15 +98,18 @@

Timeline

{% if events %}
{% for event in events.all %} -
-
- {{ event.icon|safe }}{{ event.timestamp|date:"H:i:s" }} - {{ event|stringformat:'s'|unslackify|markdown_filter|safe }} +
+
+ + {{ event.icon|safe }}{{ event.timestamp|date:"H:i:s" }} + + {{ event|stringformat:'s'|unslackify|markdown_filter|safe }} +
-
{% endfor %}
{% endif %} +
From 4a794da669fe8c6b8b9a8d6c5d328a16545a67b5 Mon Sep 17 00:00:00 2001 From: Dan Palmer Date: Sat, 14 Sep 2019 15:29:48 +0100 Subject: [PATCH 08/20] Move messages to share the same Bootstrap container This is preparation for the next commit... --- response/templates/response/base.html | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/response/templates/response/base.html b/response/templates/response/base.html index 98db1c4b..fb3eb71c 100644 --- a/response/templates/response/base.html +++ b/response/templates/response/base.html @@ -45,9 +45,9 @@
- - {% block messages %} -
+
+ + {% block messages %}
{% for message in messages %}
@@ -55,11 +55,9 @@
{% endfor %}
-
- {% endblock %} + {% endblock %} - -
+ {% block content %}{% endblock %}
From 0eb5c9fc916b2d49c689fd889f67bc21862a3783 Mon Sep 17 00:00:00 2001 From: Dan Palmer Date: Sat, 14 Sep 2019 15:36:22 +0100 Subject: [PATCH 09/20] Make it possible to override these container classes This creates a customisation point for wide-screen layouts. This may be desirable for, say, a dashboard of in-progress incidents on a TV in an office. --- response/templates/response/base.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/response/templates/response/base.html b/response/templates/response/base.html index fb3eb71c..cab20f82 100644 --- a/response/templates/response/base.html +++ b/response/templates/response/base.html @@ -27,7 +27,7 @@ -
+
{% block messages %} + {% endblock %}
From 26e7d3f80dcd91cf40d03bb1931d8674d3ba999d Mon Sep 17 00:00:00 2001 From: Dan Palmer Date: Sat, 14 Sep 2019 15:41:28 +0100 Subject: [PATCH 11/20] Reflow/quoting changes, no functional changes This fixes some syntax highlighting issues in common editors (VSCode, Sublime Text), and makes indentation more consistent, etc. --- response/templates/response/base.html | 54 ++++++++++++++++----------- 1 file changed, 32 insertions(+), 22 deletions(-) diff --git a/response/templates/response/base.html b/response/templates/response/base.html index 38a109a6..38ac7e81 100644 --- a/response/templates/response/base.html +++ b/response/templates/response/base.html @@ -6,7 +6,7 @@ Response - + @@ -14,10 +14,10 @@ - + - - + + {% block head %}{% endblock %} @@ -27,27 +27,36 @@ {% block navigation %} - + {% endblock %}
+ {% block messages %}
@@ -61,10 +70,11 @@ {% block content %}{% endblock %} +
- + {% block javascript %}{% endblock %} From 43c5f357d2f106612187a94356de9f7b4e59ad37 Mon Sep 17 00:00:00 2001 From: Dan Palmer Date: Sat, 14 Sep 2019 15:51:08 +0100 Subject: [PATCH 12/20] Util to get settings in Response --- response/templatetags/response_settings.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 response/templatetags/response_settings.py diff --git a/response/templatetags/response_settings.py b/response/templatetags/response_settings.py new file mode 100644 index 00000000..3eae4eca --- /dev/null +++ b/response/templatetags/response_settings.py @@ -0,0 +1,15 @@ +from django import template +from django.conf import settings + +register = template.Library() + + +@register.simple_tag +def response_setting(name): + if not name.startswith("RESPONSE_"): + raise ValueError( + "This template tag only supports getting settings for the response " + "app, as accessing settings from templates is not secure by " + "default." + ) + return getattr(settings, name, None) From ba1cecdcf5fa1c17d2ae41dbd8a73bfffd0a1f8a Mon Sep 17 00:00:00 2001 From: Dan Palmer Date: Sat, 14 Sep 2019 15:51:25 +0100 Subject: [PATCH 13/20] Make the app name configurable --- response/apps.py | 3 +++ response/templates/response/base.html | 7 ++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/response/apps.py b/response/apps.py index 612f1325..f2024f21 100644 --- a/response/apps.py +++ b/response/apps.py @@ -21,3 +21,6 @@ def ready(self): site_settings.RESPONSE_LOGIN_REQUIRED = getattr( site_settings, "RESPONSE_LOGIN_REQUIRED", True ) + site_settings.RESPONSE_APP_NAME = getattr( + site_settings, "RESPONSE_APP_NAME", "Response" + ) diff --git a/response/templates/response/base.html b/response/templates/response/base.html index 38ac7e81..b322e7b4 100644 --- a/response/templates/response/base.html +++ b/response/templates/response/base.html @@ -1,16 +1,17 @@ {% load static %} +{% load response_settings %} {% load bootstrap4_alerts %} - Response + {% response_setting "RESPONSE_APP_NAME" %} - + @@ -31,7 +32,7 @@
diff --git a/response/templatetags/response_settings.py b/response/templatetags/response_settings.py deleted file mode 100644 index 3eae4eca..00000000 --- a/response/templatetags/response_settings.py +++ /dev/null @@ -1,15 +0,0 @@ -from django import template -from django.conf import settings - -register = template.Library() - - -@register.simple_tag -def response_setting(name): - if not name.startswith("RESPONSE_"): - raise ValueError( - "This template tag only supports getting settings for the response " - "app, as accessing settings from templates is not secure by " - "default." - ) - return getattr(settings, name, None) From 77b9d9478a8b21b4f1256df3de369a9b312589ce Mon Sep 17 00:00:00 2001 From: Dan Palmer Date: Fri, 27 Sep 2019 16:24:55 +0100 Subject: [PATCH 19/20] Add more customisation points MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Rough pattern followed is to wrap sections in a {% block foo %}, but include a {% block foo_extra %} at the end of that section as well, allowing for multiple ways of customising – full overrides or easy additions. Note: {{block.super}} will achieve similar, but isn't as nice an API. --- response/templates/response/base.html | 51 ++++---- response/templates/response/incident_doc.html | 123 ++++++++++-------- 2 files changed, 93 insertions(+), 81 deletions(-) diff --git a/response/templates/response/base.html b/response/templates/response/base.html index 9c8206f9..faf7de52 100644 --- a/response/templates/response/base.html +++ b/response/templates/response/base.html @@ -5,33 +5,34 @@ - - {% block title %} - Response + {% block head %} + <title> + {% block title %} + Response + {% endblock %} + + + {% block favicon %} + {% endblock %} - - {% block favicon %} - - {% endblock %} + {% block meta %} + + + + + + + {% endblock %} - {% block meta %} - - - - - - - {% endblock %} + {% block static %} + + + + {% endblock %} - {% block static %} - - - + {% block head_extra %}{% endblock %} {% endblock %} - - {% block head %}{% endblock %} - @@ -87,8 +88,10 @@
- - {% block javascript %}{% endblock %} + {% block javascript %} + + {% block javascript_extra %}{% endblock %} + {% endblock %} diff --git a/response/templates/response/incident_doc.html b/response/templates/response/incident_doc.html index 3728e4bb..ad8913c3 100644 --- a/response/templates/response/incident_doc.html +++ b/response/templates/response/incident_doc.html @@ -8,7 +8,7 @@ Inc #{{ incident.pk }} – {{ block.super }} {% endblock %} -{% block head %} +{% block head_extra %} {% endblock %} @@ -39,53 +39,60 @@

{% comment %} ----- Summary ----- {% endcomment %} -

Summary

-

- {% if incident.summary %} - {{ incident.summary|unslackify|markdown_filter|safe }} - {% endif %} -

+ {% block incident_summary %} +

Summary

+

+ {% if incident.summary %} + {{ incident.summary|unslackify|markdown_filter|safe }} + {% endif %} +

+ {% endblock %} + + {% block incident_data %} +
    + {% if incident.impact %} +
  • + Impact:{{ incident.impact|unslackify|markdown_filter|safe }} +
  • + {% endif %} + +
  • Reporter:{{ incident.reporter.display_name }}
  • + + {% if incident.lead %} +
  • Lead:{{ incident.lead.display_name }}
  • + {% endif %} -
      - {% if incident.impact %}
    • - Impact:{{ incident.impact|unslackify|markdown_filter|safe }} + Start Time: + {% if incident.start_time %}{{ incident.start_time }}{% endif %}
    • - {% endif %} - -
    • Reporter:{{ incident.reporter.display_name }}
    • - - {% if incident.lead %} -
    • Lead:{{ incident.lead.display_name }}
    • - {% endif %} - -
    • - Start Time: - {% if incident.start_time %}{{ incident.start_time }}{% endif %} -
    • -
    • - Report Time: - {% if incident.report_time %}{{ incident.report_time }}{% endif %} -
    • - - {% if incident.is_closed %} -
    • End Time:{{ incident.end_time }}
    • -
    • Duration:{{ incident.duration}}
    • - {% endif %} - - {% if user_stats %}
    • - Participants: -
        - {% for stats in user_stats %} -
      • - {{ stats.user.display_name }} ({{stats.message_count}} messages) -
      • - {% endfor %} -
      + Report Time: + {% if incident.report_time %}{{ incident.report_time }}{% endif %}
    • - {% endif %} -
    + + {% if incident.is_closed %} +
  • End Time:{{ incident.end_time }}
  • +
  • Duration:{{ incident.duration}}
  • + {% endif %} + + {% if user_stats %} +
  • + Participants: +
      + {% for stats in user_stats %} +
    • + {{ stats.user.display_name }} ({{stats.message_count}} messages) +
    • + {% endfor %} +
    +
  • + {% endif %} + + {% block incident_data_extra %} + {% endblock %} +
+ {% endblock %} {% comment %} ----- Actions ----- {% endcomment %}

Actions

@@ -98,21 +105,23 @@

Actions

{% endif %} {% comment %} ----- Timeline ----- {% endcomment %} -

Timeline

- {% if events %} -
- {% for event in events.all %} -
-
- - {{ event.icon|safe }}{{ event.timestamp|date:"H:i:s" }} - - {{ event|stringformat:'s'|unslackify|markdown_filter|safe }} + {% block incident_timeline %} +

Timeline

+ {% if events %} +
+ {% for event in events.all %} +
+
+ + {{ event.icon|safe }}{{ event.timestamp|date:"H:i:s" }} + + {{ event|stringformat:'s'|unslackify|markdown_filter|safe }} +
-
- {% endfor %} -
- {% endif %} + {% endfor %} +
+ {% endif %} + {% endblock %}
From f6ae3b42d120e1a0b38eed9880109de2a5ec8b04 Mon Sep 17 00:00:00 2001 From: Dan Palmer Date: Tue, 5 Jan 2021 15:14:45 +0000 Subject: [PATCH 20/20] Move home page into namespaced dir and format --- response/templates/home.html | 31 ------------------------ response/templates/response/home.html | 35 +++++++++++++++++++++++++++ response/ui/views.py | 4 ++- 3 files changed, 38 insertions(+), 32 deletions(-) delete mode 100644 response/templates/home.html create mode 100644 response/templates/response/home.html diff --git a/response/templates/home.html b/response/templates/home.html deleted file mode 100644 index d0486afe..00000000 --- a/response/templates/home.html +++ /dev/null @@ -1,31 +0,0 @@ -{% extends "base.html" %} -{% load static %} -{% load unslackify %} -{% load markdown_filter %} - -{% block head %} - -{% endblock %} - - -{% block content %} -
-
- {% comment %} ----- Heading ----- {% endcomment %} -

Incidents

-
- -
-
    - {% for incident in incidents %} -
  • - {{ incident.severity_emoji }} - Incident {{ incident.pk }}  - {{ incident.status_text|upper }} - - {{ incident.report }} -
  • - {% endfor %} -
-
-
-{% endblock %} diff --git a/response/templates/response/home.html b/response/templates/response/home.html new file mode 100644 index 00000000..7e430a0f --- /dev/null +++ b/response/templates/response/home.html @@ -0,0 +1,35 @@ +{% extends "response/base.html" %} +{% load static %} +{% load unslackify %} +{% load markdown_filter %} + +{% block head %} + +{% endblock %} + + +{% block content %} +
+
+ {% comment %} ----- Heading ----- {% endcomment %} +

Incidents

+
+ +
+
    + {% for incident in incidents %} +
  • + {{ incident.severity_emoji }} + + Incident {{ incident.pk }}  + + + {{ incident.status_text|upper }} + + - {{ incident.report }} +
  • + {% endfor %} +
+
+
+{% endblock %} diff --git a/response/ui/views.py b/response/ui/views.py index f59f7796..7f7443cb 100644 --- a/response/ui/views.py +++ b/response/ui/views.py @@ -9,7 +9,9 @@ @response_login_required def home(request: HttpRequest): incidents = Incident.objects.all - return render(request, template_name="home.html", context={"incidents": incidents}) + return render( + request, template_name="response/home.html", context={"incidents": incidents} + ) @response_login_required