Skip to content
Open
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
6 changes: 3 additions & 3 deletions NEMO/templates/customizations/customizations_upload.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{% load static %}
{% load custom_tags_and_filters %}
{% with element_name=name.split|join:"_"|lower extension=extension|default:"html" %}
{% file_url file_name=element_name|concat:"."|concat:extension as element_file_url %}
<form method="POST"
action="{% url 'customize' key element_name %}#{{ element_name }}_id"
enctype="multipart/form-data">
Expand All @@ -12,7 +13,7 @@
onchange="this.style.color = 'inherit';$('#{{ element_name }}_span').hide()">
{% if element %}
<a id="{{ element_name }}_span"
href="{% get_media_prefix %}{{ element_name }}.{{ extension }}"
href="{{ element_file_url }}"
download="{{ element_name }}.{{ extension }}"
target="_blank">{{ element_link_name|default:element_name }}.{{ extension }}</a>
{% endif %}
Expand All @@ -25,8 +26,7 @@
</div>
{% if element and not hide_content %}
<div style="display: inline-block;margin-top: 15px">
{% get_media_prefix as media_prefix %}
{% button type="info" url=media_prefix|concat:element_name|concat:"."|concat:extension target="_blank" value="Show current content" icon="glyphicon-eye-open" %}
{% button type="info" url=element_file_url target="_blank" value="Show current content" icon="glyphicon-eye-open" %}
</div>
{% endif %}
</div>
Expand Down
2 changes: 1 addition & 1 deletion NEMO/templates/jumbotron/jumbotron.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<title>Jumbotron</title>
</head>
<body class="jumbotron-body"
style="{% if watermark %}background-image:linear-gradient(rgba(255,255,255,0.5), rgba(255,255,255,0.5)), url('{{ MEDIA_URL }}jumbotron_watermark.png'){% endif %}">
style="{% if watermark %}background-image:linear-gradient(rgba(255,255,255,0.5), rgba(255,255,255,0.5)), url('{% file_url file_name="jumbotron_watermark.png" %}'){% endif %}">
<div id="jumbotron-container" style="min-height: calc(100vh - 61px); padding:10px 30px 0 30px">
<div class="container-fluid" style="background:transparent">
<div class="row" id="content" style="background:transparent"></div>
Expand Down
2 changes: 1 addition & 1 deletion NEMO/templates/safety/safety_data_sheets.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
<img style="display:block;
width: 100%"
alt="{{ hazard.name }} logo"
src="{% get_media_prefix %}{{ hazard.logo }}" />
src="{{ hazard.logo.url }}" />
</th>
{% endfor %}
<th class="sds-box-shadow-bottom"
Expand Down
7 changes: 7 additions & 0 deletions NEMO/templatetags/custom_tags_and_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from django import template
from django.contrib.contenttypes.models import ContentType
from django.core.files.storage import default_storage
from django.shortcuts import resolve_url
from django.template import Context, Template
from django.template.defaultfilters import date, time
Expand Down Expand Up @@ -104,6 +105,12 @@ def navigation_url(url_name, description, *conditions):
return ""


@register.simple_tag
def file_url(file_name):
if file_name and default_storage.exists(file_name):
return default_storage.url(file_name)


@register.simple_tag
def res_question_tbody(dictionary):
input_dict = dictionary[list(dictionary.keys())[0]]
Expand Down