diff --git a/.gitattributes b/.gitattributes index 9417a00d..fb1e242b 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,2 +1,2 @@ *.sh text eol=lf -static/bootstrap/* linguist-vendored=true +response/static/bootstrap/* linguist-vendored=true diff --git a/response/templates/base.html b/response/templates/base.html deleted file mode 100644 index 15a3b4fb..00000000 --- a/response/templates/base.html +++ /dev/null @@ -1,59 +0,0 @@ -{% load static %} - - - - - - Response - - - - - - - - - - - - - - {% block head %}{% endblock %} - - - - - - - - - -
- {% block content %}{% endblock %} -
- - - {% comment %} {% endcomment %} - - {% block javascript %}{% endblock %} - - - - 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

-
- -
- -
-
-{% endblock %} diff --git a/response/templates/incident_doc.html b/response/templates/incident_doc.html deleted file mode 100644 index 6017bb18..00000000 --- a/response/templates/incident_doc.html +++ /dev/null @@ -1,79 +0,0 @@ -{% extends "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 %} ----- Summary ----- {% endcomment %} -

Summary

-

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

- - {% comment %} ----- Actions ----- {% endcomment %} -

Actions

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

Timeline

- {% if incident.timeline_events %} -
- {% for event in incident.timeline_events.all %} -
-
- {{ event.timestamp|date:"H:i:s" }} - {{ event.text|stringformat:'s'|unslackify|markdown_filter|safe }} -
-
- {% endfor %} -
- {% endif %} - -
-
-{% endblock %} diff --git a/response/templates/response/base.html b/response/templates/response/base.html new file mode 100644 index 00000000..faf7de52 --- /dev/null +++ b/response/templates/response/base.html @@ -0,0 +1,98 @@ +{% load static %} +{% load bootstrap4_alerts %} + + + + + + {% block head %} + + {% block title %} + Response + {% endblock %} + + + {% block favicon %} + + {% endblock %} + + {% block meta %} + + + + + + + {% endblock %} + + {% block static %} + + + + {% endblock %} + + {% block head_extra %}{% endblock %} + {% endblock %} + + + + + + {% block navigation %} + + {% endblock %} + +
+ + + {% block messages %} +
+ {% for message in messages %} +
+ {{ message }} +
+ {% endfor %} +
+ {% endblock %} + + + {% block content %}{% endblock %} + +
+ + + {% block javascript %} + + {% block javascript_extra %}{% endblock %} + {% 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

+
+ +
+ +
+
+{% endblock %} diff --git a/response/templates/response/incident_doc.html b/response/templates/response/incident_doc.html new file mode 100644 index 00000000..ad8913c3 --- /dev/null +++ b/response/templates/response/incident_doc.html @@ -0,0 +1,129 @@ +{% extends "response/base.html" %} + +{% load static %} +{% load unslackify %} +{% load markdown_filter %} + +{% block title %} + Inc #{{ incident.pk }} – {{ block.super }} +{% endblock %} + +{% block head_extra %} + +{% endblock %} + +{% block content %} +
+ +
+
+ + {% comment %} ----- Heading ----- {% endcomment %} +

+ Incident {{ incident.pk }} +

+ +
+ + {{ incident.status_text|upper }} + + {% if incident.severity_text %} + - {{ incident.severity_text|upper}} SEVERITY + {% endif %} +
+ +
+
+ +
+
+ + {% comment %} ----- Summary ----- {% endcomment %} + {% 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 %} + +
  • + 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 %} +
    +
  • + {% endif %} + + {% block incident_data_extra %} + {% endblock %} +
+ {% endblock %} + + {% comment %} ----- Actions ----- {% endcomment %} +

Actions

+ {% if actions %} +
    + {% for action in actions.all %} +
  • {{ action.details|unslackify|markdown_filter|safe }}
  • + {% endfor %} +
+ {% endif %} + + {% comment %} ----- Timeline ----- {% endcomment %} + {% 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 %} + {% endblock %} + +
+
+
+{% 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}" diff --git a/response/ui/views.py b/response/ui/views.py index 03281f6c..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 @@ -26,7 +28,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,