Skip to content

Commit

Permalink
Add more customisation points
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
danpalmer committed Jan 5, 2021
1 parent 3e1ff04 commit 77b9d94
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 81 deletions.
51 changes: 27 additions & 24 deletions response/templates/response/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,34 @@
<html lang="en">

<head>
<title>
{% block title %}
Response
{% block head %}
<title>
{% block title %}
Response
{% endblock %}
</title>

{% block favicon %}
<link rel="shortcut icon" href="{% static 'images/favicon.png' %}">
{% endblock %}
</title>

{% block favicon %}
<link rel="shortcut icon" href="{% static 'images/favicon.png' %}">
{% endblock %}
{% block meta %}
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="Response">
<meta name="author" content="Monzo">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes">
{% endblock %}

{% block meta %}
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="Response">
<meta name="author" content="Monzo">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes">
{% endblock %}
{% block static %}
<link rel="manifest" href="{% static 'manifest.json' %}">
<link href="{% static 'bootstrap/css/bootstrap.css' %}" rel="stylesheet">
<link href="{% static 'common.css' %}" rel="stylesheet">
{% endblock %}

{% block static %}
<link rel="manifest" href="{% static 'manifest.json' %}">
<link href="{% static 'bootstrap/css/bootstrap.css' %}" rel="stylesheet">
<link href="{% static 'common.css' %}" rel="stylesheet">
{% block head_extra %}{% endblock %}
{% endblock %}

{% block head %}{% endblock %}

</head>

<body>
Expand Down Expand Up @@ -87,8 +88,10 @@
</div>

<!-- Bootstrap core JavaScript -->
<script src="{% static 'bootstrap/js/bootstrap.bundle.min.js' %}"></script>
{% block javascript %}{% endblock %}
{% block javascript %}
<script src="{% static 'bootstrap/js/bootstrap.bundle.min.js' %}"></script>
{% block javascript_extra %}{% endblock %}
{% endblock %}

</body>

Expand Down
123 changes: 66 additions & 57 deletions response/templates/response/incident_doc.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
Inc #{{ incident.pk }} – {{ block.super }}
{% endblock %}

{% block head %}
{% block head_extra %}
<link rel="stylesheet" href="{% static 'incident_doc.css' %}">
{% endblock %}

Expand Down Expand Up @@ -39,53 +39,60 @@ <h1 id="title">
<div class="bg-white p-4">

{% comment %} ----- Summary ----- {% endcomment %}
<h2>Summary</h2>
<p>
{% if incident.summary %}
{{ incident.summary|unslackify|markdown_filter|safe }}
{% endif %}
</p>
{% block incident_summary %}
<h2>Summary</h2>
<p>
{% if incident.summary %}
{{ incident.summary|unslackify|markdown_filter|safe }}
{% endif %}
</p>
{% endblock %}

{% block incident_data %}
<ul class="summary-data">
{% if incident.impact %}
<li>
<span>Impact:</span>{{ incident.impact|unslackify|markdown_filter|safe }}
</li>
{% endif %}

<li><span>Reporter:</span>{{ incident.reporter.display_name }}</li>

{% if incident.lead %}
<li><span>Lead:</span>{{ incident.lead.display_name }}</li>
{% endif %}

<ul class="summary-data">
{% if incident.impact %}
<li>
<span>Impact:</span>{{ incident.impact|unslackify|markdown_filter|safe }}
<span>Start Time:</span>
{% if incident.start_time %}{{ incident.start_time }}{% endif %}
</li>
{% endif %}

<li><span>Reporter:</span>{{ incident.reporter.display_name }}</li>

{% if incident.lead %}
<li><span>Lead:</span>{{ incident.lead.display_name }}</li>
{% endif %}

<li>
<span>Start Time:</span>
{% if incident.start_time %}{{ incident.start_time }}{% endif %}
</li>
<li>
<span>Report Time:</span>
{% if incident.report_time %}{{ incident.report_time }}{% endif %}
</li>

{% if incident.is_closed %}
<li><span>End Time:</span>{{ incident.end_time }}</li>
<li><span>Duration:</span>{{ incident.duration}}</li>
{% endif %}

{% if user_stats %}
<li>
<span>Participants:</span>
<ul id="participant">
{% for stats in user_stats %}
<li>
{{ stats.user.display_name }} ({{stats.message_count}} messages)
</li>
{% endfor %}
</ul>
<span>Report Time:</span>
{% if incident.report_time %}{{ incident.report_time }}{% endif %}
</li>
{% endif %}
</ul>

{% if incident.is_closed %}
<li><span>End Time:</span>{{ incident.end_time }}</li>
<li><span>Duration:</span>{{ incident.duration}}</li>
{% endif %}

{% if user_stats %}
<li>
<span>Participants:</span>
<ul id="participant">
{% for stats in user_stats %}
<li>
{{ stats.user.display_name }} ({{stats.message_count}} messages)
</li>
{% endfor %}
</ul>
</li>
{% endif %}

{% block incident_data_extra %}
{% endblock %}
</ul>
{% endblock %}

{% comment %} ----- Actions ----- {% endcomment %}
<h2>Actions</h2>
Expand All @@ -98,21 +105,23 @@ <h2>Actions</h2>
{% endif %}

{% comment %} ----- Timeline ----- {% endcomment %}
<h2>Timeline</h2>
{% if events %}
<div class="timeline">
{% for event in events.all %}
<div class="container">
<div class="content">
<strong>
{{ event.icon|safe }}{{ event.timestamp|date:"H:i:s" }}
</strong>
{{ event|stringformat:'s'|unslackify|markdown_filter|safe }}
{% block incident_timeline %}
<h2>Timeline</h2>
{% if events %}
<div class="timeline">
{% for event in events.all %}
<div class="container">
<div class="content">
<strong>
{{ event.icon|safe }}{{ event.timestamp|date:"H:i:s" }}
</strong>
{{ event|stringformat:'s'|unslackify|markdown_filter|safe }}
</div>
</div>
</div>
{% endfor %}
</div>
{% endif %}
{% endfor %}
</div>
{% endif %}
{% endblock %}

</div>
</div>
Expand Down

0 comments on commit 77b9d94

Please sign in to comment.