Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update flash update export pdf file #2323

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions flash_update/templatetags/tags.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
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
# NOTE: This should point to the goadmin FullURL
if StorageClass == FileSystemStorage:
if settings.DEBUG:
return f"http://serve:8000{path}"
return f"https://{settings.BASE_URL}{path}"
return path
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>