Skip to content

Commit

Permalink
moved message to show across entire service
Browse files Browse the repository at this point in the history
  • Loading branch information
Pheonnexx committed Oct 25, 2022
1 parent dc3fed6 commit 1307e69
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 12 deletions.
7 changes: 1 addition & 6 deletions cla_public/apps/contact/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,8 @@ class Contact(AllowSessionOverride, UpdatesMeansTest, SessionBackedFormView):
template = "contact.html"

def get(self, *args, **kwargs):
self.template_context = {
"emergency_message": current_app.config["EMERGENCY_MESSAGE_ON"],
"emergency_message_title": current_app.config["EMERGENCY_MESSAGE_TITLE"],
"emergency_message_text": current_app.config["EMERGENCY_MESSAGE_TEXT"],
}
if ReasonsForContacting.GA_SESSION_KEY in session:
self.template_context.update({"reasons_for_contacting": session[ReasonsForContacting.GA_SESSION_KEY]})
self.template_context = {"reasons_for_contacting": session[ReasonsForContacting.GA_SESSION_KEY]}
del session[ReasonsForContacting.GA_SESSION_KEY]
return super(Contact, self).get(*args, **kwargs)

Expand Down
10 changes: 9 additions & 1 deletion cla_public/django_to_jinja.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import sys
import datetime

from flask import Blueprint, url_for
from flask import Blueprint, url_for, current_app
from flask.ext.markdown import Markdown
import jinja2

Expand Down Expand Up @@ -56,6 +56,14 @@ def moj_variables():
log.critical("Cannot find APP_SETTINGS group in the configuration file.")
sys.exit(1)

@app.context_processor
def emergency_message_settings():
return {
"emergency_message_on": current_app.config["EMERGENCY_MESSAGE_ON"],
"emergency_message_title": current_app.config["EMERGENCY_MESSAGE_TITLE"],
"emergency_message_text": current_app.config["EMERGENCY_MESSAGE_TEXT"],
}

# get today's date
@app.context_processor
def covid_availability_times():
Expand Down
11 changes: 10 additions & 1 deletion cla_public/templates/base.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{% extends "moj_template_base.jinja" %}

{% import "macros/element.html" as Element %}
{% import "macros/emergency_message.html" as Message %}

{% block page_title %}{{ app_title }}{% endblock %}

Expand Down Expand Up @@ -84,8 +85,16 @@
</div>
{% endif %}
{% endwith %}
<div class="govuk-grid-column-two-thirds">
{% block session_timeout_dialog %} {% include "_modal-dialog.html" %} {% endblock %}
<div class="govuk-grid-column-full">
{% block emergency_message_block %}
{% if emergency_message_on %}
{% call Message.emergency_message(emergency_message_title, emergency_message_text) %}
{% endcall %}
{% endif %}
{% endblock %}
</div>
<div class="govuk-grid-column-two-thirds">
{% block inner_content %}{% endblock %}
</div>
<div class="govuk-grid-column-one-third">
Expand Down
4 changes: 0 additions & 4 deletions cla_public/templates/contact.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,11 @@
{% import "macros/form.html" as Form %}
{% import "macros/subform.html" as Subform %}
{% import "macros/element.html" as Element %}
{% import "macros/emergency_message.html" as EmergencyMessage %}

{% set title = _('Contact Civil Legal Advice') %}
{% block page_title %}{{ title }}{% endblock %}

{% block inner_content %}
{% if emergency_message %}
{{ EmergencyMessage(emergency_title, emergency_text) }}
{% endif %}
{{ Form.handle_errors(form) }}
{% block page_text %}
{% if config.CONTACT_ONLY %}
Expand Down
1 change: 1 addition & 0 deletions cla_public/templates/macros/emergency_message.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ <h2 class="govuk-notification-banner__title" id="govuk-notification-banner-title
<p class="govuk-notification-banner__heading">
<h3 class="govuk-heading-m">{{ emergency_message_title }}</h3>
{{ emergency_message_text }}
{{ caller() }}
</p>
</div>
</div>
Expand Down

0 comments on commit 1307e69

Please sign in to comment.