From 2e28fa3c9f5028d34f4e8986476fb866e48770cf Mon Sep 17 00:00:00 2001 From: Dan Palmer Date: Fri, 27 Sep 2019 16:24:55 +0100 Subject: [PATCH] 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 7bd358bf..7d2c344d 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,70 +39,79 @@

{% 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 %} ----- 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 %}