Skip to content

Commit

Permalink
Change flash update html export
Browse files Browse the repository at this point in the history
  • Loading branch information
susilnem committed Nov 29, 2024
1 parent 636bae1 commit 0754607
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 27 deletions.
17 changes: 17 additions & 0 deletions flash_update/templatetags/tags.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from django import template
from django.conf import settings
from django.core.files.storage import FileSystemStorage, get_storage_class

register = template.Library()

StorageClass = get_storage_class()


@register.filter(is_safe=True)
def media_full_path(path):
# TODO: Refactor http and https
if StorageClass == FileSystemStorage:
if settings.DEBUG:
return f"http://serve:8000{path}" # Don't use this in production
return f"https://{settings.BASE_URL}{path}"
return path
1 change: 0 additions & 1 deletion flash_update/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,4 @@ def get_email_context(instance):
"actions_taken": actions_taken,
"resources": resources,
}
email_context = {key: value for key, value in email_context.items() if value is not None}
return email_context
1 change: 1 addition & 0 deletions main/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@

ALLOWED_HOSTS = [
"localhost",
"serve",
"0.0.0.0",
GO_API_FQDN,
*env("DJANGO_ADDITIONAL_ALLOWED_HOSTS"),
Expand Down
81 changes: 55 additions & 26 deletions notifications/templates/email/flash_update/flash_pdf.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{% load static %}
{% load tags %}

<!DOCTYPE html>
<html>
<style>
Expand Down Expand Up @@ -36,9 +39,22 @@
padding-left: 20px;
text-decoration: none;
}
.figure {
display: block;
margin: 0;
padding: 0;
text-align: center;
}
.caption {
font-size: 13px;
padding-left: 6px;
display: block;
text-align: center;
}
.image {
max-width: 100%;
height: 300px;
width: auto;
margin: 0 auto;
}
#situational_overview{
font-size: 15px;
Expand All @@ -54,53 +70,66 @@ <h1 class="title-heading-main">{{title}}</h1>
<h2 class="heading">Situational Overview</h2>
<div id="situational_overview"><p> {{situational_overview|safe}}</p></div>

<h2 class="heading">Graphics and Maps</h2>

{% if not map_list|length == 0 %}
<table>
<tr>
<h2 class="heading">Graphics and Maps</h2>
{% for map in map_list %}
<td><img style='width:100%; height:100%;' src="{{map.image}}" alt="image"><br><p class='caption'>{{map.caption}}</p></td>
<figure class='figure'>
<img class='image' src="{{ map.image | media_full_path }}" alt="image" />
{% if map.caption %}
<figcaption class='caption'>{{map.caption}}</figcaption>
{% endif %}
</figure>
{% endfor %}
</tr>
</table>
{% endif %}

{% if not graphic_list|length == 0 %}
<table>
<tr>
{% if graphic_list|length > 0 %}
{% for graphic in graphic_list %}
<td><img style='width:100%; height:100%;' src="{{graphic.image}}" alt="image"><br><p class='caption'>{{graphic.caption}}</p></td>
<figure class="figure">
<img class='image' src="{{ graphic.image | media_full_path}}" alt="image" />
{% if graphic.caption %}
<figcaption class='caption'>{{graphic.caption}}</figcaption>
{% endif %}
</figure>
{% endfor %}
</tr>
</table>
{% endif %}

<h2 class="heading">Actions Taken</h2>
{% if not actions_taken|length == 0 %}
<h2 class="heading">Actions Taken</h2>
{% for act_taken in actions_taken %}
{% if not act_taken.action_details|length == 0 or act_taken.summary %}
<p class="sub-heading">Actions Taken by {{act_taken.organization_display}}</p>

{% for act_taken in actions_taken %}
<p class="sub-heading">Actions Taken by {{act_taken.organization_display}}</p>
{% if act_taken.summary %}
<p class="sub-heading">Descriptions</p>
<span class='desc'>{{act_taken.summary|linebreaks}}</span>
{% endif %}

<p class="sub-heading">Descriptions</p>
<span class='desc'>{{act_taken.summary|linebreaks}}</span>

<p class="sub-heading">Actions</p>
{% for action in act_taken.action_details %}
<p class="actions">{{action.name}}</p>
{%endfor%}
{% if not act_taken.action_details|length == 0 %}
<p class="sub-heading">Actions</p>
{% for action in act_taken.action_details %}
<p class="actions">{{action.name}}</p>
{%endfor%}
{% endif %}
{% endif %}
{% endfor %}

{% endif %}

{% if not resources|length == 0 %}
<h2 class="heading">Resources</h2>
{% for resource in resources %}
<p class="desc">{{resource.date}} <br>
{{resource.source_description}} <br>
{% if resource.source_description %}
{{resource.source_description}} <br>
{% endif %}
{% if resource.url %}
<a class="actions">{{resource.url}}</a><br>
{% endif %}
{% if resource.flash_file %}
<a class="actions" href={{resource.flash_file}}> Download document</a>
{% endif %}
</p>
{%endfor%}
{% endfor %}
{% endif %}
</body>
</html>

0 comments on commit 0754607

Please sign in to comment.