Skip to content

Commit 424f3ad

Browse files
committed
Change flash update html export
1 parent 636bae1 commit 424f3ad

File tree

4 files changed

+74
-27
lines changed

4 files changed

+74
-27
lines changed

flash_update/templatetags/tags.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from django import template
2+
from django.conf import settings
3+
from django.core.files.storage import FileSystemStorage, get_storage_class
4+
5+
register = template.Library()
6+
7+
StorageClass = get_storage_class()
8+
9+
10+
@register.filter(is_safe=True)
11+
def media_full_path(path):
12+
# TODO: Refactor http and https
13+
# NOTE: This should point to the goadmin FullURL
14+
if StorageClass == FileSystemStorage:
15+
if settings.DEBUG:
16+
return f"http://serve:8000{path}"
17+
return f"https://{settings.BASE_URL}{path}"
18+
return path

flash_update/utils.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,4 @@ def get_email_context(instance):
5959
"actions_taken": actions_taken,
6060
"resources": resources,
6161
}
62-
email_context = {key: value for key, value in email_context.items() if value is not None}
6362
return email_context

main/settings.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@
137137

138138
ALLOWED_HOSTS = [
139139
"localhost",
140+
"serve",
140141
"0.0.0.0",
141142
GO_API_FQDN,
142143
*env("DJANGO_ADDITIONAL_ALLOWED_HOSTS"),

notifications/templates/email/flash_update/flash_pdf.html

Lines changed: 55 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
{% load static %}
2+
{% load tags %}
3+
14
<!DOCTYPE html>
25
<html>
36
<style>
@@ -36,9 +39,22 @@
3639
padding-left: 20px;
3740
text-decoration: none;
3841
}
42+
.figure {
43+
display: block;
44+
margin: 0;
45+
padding: 0;
46+
text-align: center;
47+
}
3948
.caption {
4049
font-size: 13px;
41-
padding-left: 6px;
50+
display: block;
51+
text-align: center;
52+
}
53+
.image {
54+
max-width: 100%;
55+
height: 300px;
56+
width: auto;
57+
margin: 0 auto;
4258
}
4359
#situational_overview{
4460
font-size: 15px;
@@ -54,53 +70,66 @@ <h1 class="title-heading-main">{{title}}</h1>
5470
<h2 class="heading">Situational Overview</h2>
5571
<div id="situational_overview"><p> {{situational_overview|safe}}</p></div>
5672

57-
<h2 class="heading">Graphics and Maps</h2>
58-
5973
{% if not map_list|length == 0 %}
60-
<table>
61-
<tr>
74+
<h2 class="heading">Graphics and Maps</h2>
6275
{% for map in map_list %}
63-
<td><img style='width:100%; height:100%;' src="{{map.image}}" alt="image"><br><p class='caption'>{{map.caption}}</p></td>
76+
<figure class='figure'>
77+
<img class='image' src="{{ map.image | media_full_path }}" alt="image" />
78+
{% if map.caption %}
79+
<figcaption class='caption'>{{map.caption}}</figcaption>
80+
{% endif %}
81+
</figure>
6482
{% endfor %}
65-
</tr>
66-
</table>
6783
{% endif %}
6884

69-
{% if not graphic_list|length == 0 %}
70-
<table>
71-
<tr>
85+
{% if graphic_list|length > 0 %}
7286
{% for graphic in graphic_list %}
73-
<td><img style='width:100%; height:100%;' src="{{graphic.image}}" alt="image"><br><p class='caption'>{{graphic.caption}}</p></td>
87+
<figure class="figure">
88+
<img class='image' src="{{ graphic.image | media_full_path}}" alt="image" />
89+
{% if graphic.caption %}
90+
<figcaption class='caption'>{{graphic.caption}}</figcaption>
91+
{% endif %}
92+
</figure>
7493
{% endfor %}
75-
</tr>
76-
</table>
7794
{% endif %}
7895

79-
<h2 class="heading">Actions Taken</h2>
96+
{% if not actions_taken|length == 0 %}
97+
<h2 class="heading">Actions Taken</h2>
98+
{% for act_taken in actions_taken %}
99+
{% if not act_taken.action_details|length == 0 or act_taken.summary %}
100+
<p class="sub-heading">Actions Taken by {{act_taken.organization_display}}</p>
80101

81-
{% for act_taken in actions_taken %}
82-
<p class="sub-heading">Actions Taken by {{act_taken.organization_display}}</p>
102+
{% if act_taken.summary %}
103+
<p class="sub-heading">Descriptions</p>
104+
<span class='desc'>{{act_taken.summary|linebreaks}}</span>
105+
{% endif %}
83106

84-
<p class="sub-heading">Descriptions</p>
85-
<span class='desc'>{{act_taken.summary|linebreaks}}</span>
86-
87-
<p class="sub-heading">Actions</p>
88-
{% for action in act_taken.action_details %}
89-
<p class="actions">{{action.name}}</p>
90-
{%endfor%}
107+
{% if not act_taken.action_details|length == 0 %}
108+
<p class="sub-heading">Actions</p>
109+
{% for action in act_taken.action_details %}
110+
<p class="actions">{{action.name}}</p>
111+
{%endfor%}
112+
{% endif %}
113+
{% endif %}
91114
{% endfor %}
92115

116+
{% endif %}
117+
118+
{% if not resources|length == 0 %}
93119
<h2 class="heading">Resources</h2>
94120
{% for resource in resources %}
95121
<p class="desc">{{resource.date}} <br>
96-
{{resource.source_description}} <br>
122+
{% if resource.source_description %}
123+
{{resource.source_description}} <br>
124+
{% endif %}
97125
{% if resource.url %}
98126
<a class="actions">{{resource.url}}</a><br>
99127
{% endif %}
100128
{% if resource.flash_file %}
101129
<a class="actions" href={{resource.flash_file}}> Download document</a>
102130
{% endif %}
103131
</p>
104-
{%endfor%}
132+
{% endfor %}
133+
{% endif %}
105134
</body>
106135
</html>

0 commit comments

Comments
 (0)