Skip to content

Commit 6ffaf15

Browse files
committed
Add maintenance page
1 parent d7358c1 commit 6ffaf15

File tree

4 files changed

+45
-3
lines changed

4 files changed

+45
-3
lines changed

app/config/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ class Config(object):
1818
SERVICE_PHASE = os.environ.get("SERVICE_PHASE", "Beta")
1919
SERVICE_URL = os.environ.get("SERVICE_URL", "")
2020
SESSION_COOKIE_HTTPONLY = True
21-
# SESSION_COOKIE_SECURE = True
2221
SENTRY_DSN = os.environ.get("SENTRY_DSN")
22+
MAINTENANCE_MODE = os.environ.get("MAINTENANCE_MODE", "False").lower() == "true"

app/main/routes.py

+24-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
1-
from flask import flash, json, make_response, redirect, render_template, request
1+
from flask import (
2+
flash,
3+
json,
4+
make_response,
5+
redirect,
6+
render_template,
7+
request,
8+
url_for,
9+
)
10+
from flask import current_app
211
from flask_wtf.csrf import CSRFError
312
from werkzeug.exceptions import HTTPException
413

@@ -11,6 +20,13 @@ def index():
1120
return render_template("index.html")
1221

1322

23+
@bp.route("/maintenance-mode", methods=["GET"])
24+
def maintenance_mode_page():
25+
if not current_app.config["MAINTENANCE_MODE"]:
26+
return redirect(url_for("main.index"))
27+
return render_template("maintenance-mode.html"), 503
28+
29+
1430
@bp.route("/accessibility", methods=["GET"])
1531
def accessibility():
1632
return render_template("accessibility.html")
@@ -65,3 +81,10 @@ def http_exception(error):
6581
def csrf_error(error):
6682
flash("The form you were submitting has expired. Please try again.")
6783
return redirect(request.full_path)
84+
85+
86+
@bp.before_request
87+
def maintenance_mode_middleware():
88+
maintenance_url = url_for("main.maintenance_mode_page")
89+
if current_app.config["MAINTENANCE_MODE"] and request.path != maintenance_url:
90+
return redirect(maintenance_url)
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{% extends "base.html" %}
2+
3+
{% block pageTitle %}This service is currently down for maintenance{% endblock %}
4+
5+
{% set mainClasses = "govuk-main-wrapper--l" %}
6+
7+
{% block content %}
8+
<div class="govuk-grid-row">
9+
<div class="govuk-grid-column-two-thirds">
10+
<h1 class="govuk-heading-l">This service is currently down for maintenance</h1>
11+
<p class="govuk-body">'If you were part way through the service, you will have to start again when the service becomes available.</p>
12+
</div>
13+
</div>
14+
{% endblock %}

helm_deploy/laa-access-civil-legal-aid/values.yaml

+6-1
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,9 @@ envVars:
7373
SENTRY_DSN:
7474
secret:
7575
name: sentry
76-
key: dsn
76+
key: dsn
77+
MAINTENANCE_MODE:
78+
configmap:
79+
name: maintenance-mode
80+
key: enabled
81+
optional: true

0 commit comments

Comments
 (0)