Skip to content
This repository has been archived by the owner on Jul 25, 2024. It is now read-only.

Commit

Permalink
Add maintenance mode page
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelhwilliams committed Jul 15, 2024
1 parent 9282b7b commit a6cbd7d
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 1 deletion.
11 changes: 10 additions & 1 deletion app/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from flask import Flask
from flask import Flask, render_template, request
from flask_assets import Environment
from flask_talisman import Talisman
from flask_wtf.csrf import CSRFProtect
Expand Down Expand Up @@ -47,6 +47,15 @@ def create_app(config_class=Config):
],
}

@app.before_request
def maintenance_page() -> str | None:
if request.endpoint != "static" and app.config["MAINTENANCE_MODE"]:
return render_template(
"main/maintenance-mode.html", maintenance_ends_from=app.config["MAINTENANCE_ENDS_FROM"]
)

return None

# Initialise app extensions
app.static_folder = "static/dist/"
assets.init_app(app)
Expand Down
2 changes: 2 additions & 0 deletions app/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
}) }}
{% endblock phaseBanner %}

{% block backLinks %}
<div class="global-actions">
{% if request.path not in [url_for('main.download'), url_for('main.start_page')] %}
{{ govukBackLink({
Expand All @@ -50,6 +51,7 @@
<a href="{{ config['AUTHENTICATOR_HOST'] + '/sso/logout' }}" class="govuk-body govuk-link govuk-link--no-underline govuk-link--no-visited-state govuk-!-margin-left-4">Log out</a>
</div>
</div>
{% endblock backLinks %}
{% endblock beforeContent %}

{% block content %}
Expand Down
26 changes: 26 additions & 0 deletions app/templates/main/maintenance-mode.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{% extends "base.html" %}

{% block pageTitle %}Sorry, the service is unavailable – {{ config['SERVICE_NAME'] }} – GOV.UK{% endblock pageTitle %}

{% block backLinks %}{% endblock backLinks %}

{# Override main width to two thirds #}
{% set mainClasses = "govuk-main-wrapper-l govuk-!-width-two-thirds" %}

{% block content %}
<div class="govuk-width-container">
<h1 class="govuk-heading-l">Sorry, the service is unavailable</h1>

{% if maintenance_ends_from %}
<p class="govuk-body">You will be able to use the service from {{ maintenance_ends_from }}</p>
{% else %}
<p class="govuk-body">You will be able to use the service later.</p>
{% endif %}

<p class="govuk-body">
<a class="govuk-link" href="mailto:{{ config['CONTACT_EMAIL'] }}">Contact the Funding Service Design support team</a> if you need help.
We aim to respond within 1 to 2 working days
</p>
<p class="govuk-body">Do not send your data return or any attachments to this email address.</p>
</div>
{% endblock content %}
4 changes: 4 additions & 0 deletions config/envs/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ class DefaultConfig(object):
FLASK_ROOT = str(Path(__file__).parent.parent.parent)
FLASK_ENV = CommonConfig.FLASK_ENV
FSD_LOG_LEVEL = logging.INFO

MAINTENANCE_MODE: bool = os.getenv("MAINTENANCE_MODE", "false").lower() in {"1", "true", "yes", "y", "on"}
MAINTENANCE_ENDS_FROM: str | None = os.getenv("MAINTENANCE_ENDS_FROM")

CONTACT_EMAIL = os.environ.get("CONTACT_EMAIL", "[email protected]").lower()
CONTACT_PHONE = os.environ.get("CONTACT_PHONE", "12345678910")
DEPARTMENT_NAME = os.environ.get("DEPARTMENT_NAME", "Department for Levelling Up, Housing and Communities")
Expand Down

0 comments on commit a6cbd7d

Please sign in to comment.