From 9a84f77ec420075fa1da9029b61e8f9487233cd5 Mon Sep 17 00:00:00 2001 From: James Graham Date: Wed, 24 Jun 2020 13:40:02 +0100 Subject: [PATCH] fix: Don't insert form CSS/JS when no form --- breccia_mapper/templates/base.html | 148 +++++++++++++++-------------- 1 file changed, 76 insertions(+), 72 deletions(-) diff --git a/breccia_mapper/templates/base.html b/breccia_mapper/templates/base.html index 3d2ddc0..b69fd7b 100644 --- a/breccia_mapper/templates/base.html +++ b/breccia_mapper/templates/base.html @@ -1,8 +1,8 @@ {% load bootstrap4 %} {% if 'use_i18n'|bootstrap_setting %} - {% load i18n %} - {% get_current_language as LANGUAGE_CODE %} +{% load i18n %} +{% get_current_language as LANGUAGE_CODE %} {% endif %} @@ -25,28 +25,29 @@ crossorigin="anonymous" /> {% load staticfiles %} - + {% if 'javascript_in_head'|bootstrap_setting %} - {% if 'include_jquery'|bootstrap_setting %} - {# jQuery JavaScript if it is in head #} - {% bootstrap_jquery jquery='include_jquery'|bootstrap_setting %} - {% endif %} - - {# Bootstrap JavaScript if it is in head #} - {% bootstrap_javascript %} + {% if 'include_jquery'|bootstrap_setting %} + {# jQuery JavaScript if it is in head #} + {% bootstrap_jquery jquery='include_jquery'|bootstrap_setting %} {% endif %} - {{ form.media.css }} + {# Bootstrap JavaScript if it is in head #} + {% bootstrap_javascript %} + {% endif %} + + {% if form %} + {{ form.media.css }} + {% endif %} {% block extra_head %}{% endblock %} -
- {% block navbar %} +
+ {% block navbar %}
- {% endblock %} + {% endblock %} - {# Global banner if config.NOTICE_TEXT is set using Constance #} - {% if config.NOTICE_TEXT %} + {# Global banner if config.NOTICE_TEXT is set using Constance #} + {% if config.NOTICE_TEXT %} - {% endif %} + {% endif %} - {% if request.user.is_authenticated and not request.user.has_person %} + {% if request.user.is_authenticated and not request.user.has_person %} - {% endif %} + {% endif %} - {% block before_content %}{% endblock %} + {% block before_content %}{% endblock %} -
- {# Display Django messages as Bootstrap alerts #} - {% bootstrap_messages %} +
+ {# Display Django messages as Bootstrap alerts #} + {% bootstrap_messages %} - {% block content %}{% endblock %} -
+ {% block content %}{% endblock %} +
-
- {% block after_content %}{% endblock %} +
+ {% block after_content %}{% endblock %} +
-
- + -{% if not 'javascript_in_head'|bootstrap_setting %} + {% if not 'javascript_in_head'|bootstrap_setting %} {% if 'include_jquery'|bootstrap_setting %} - {# jQuery JavaScript if it is in body #} - {% bootstrap_jquery jquery='include_jquery'|bootstrap_setting %} + {# jQuery JavaScript if it is in body #} + {% bootstrap_jquery jquery='include_jquery'|bootstrap_setting %} {% endif %} {# Bootstrap JavaScript if it is in body #} {% bootstrap_javascript %} -{% endif %} + {% endif %} -{{ form.media.js }} + {% if form %} + {{ form.media.js }} + {% endif %} -{% block extra_script %}{% endblock %} + {% block extra_script %}{% endblock %}