-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5f742ee
commit 9bd6d97
Showing
5 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from django.http import HttpResponseRedirect | ||
from django.urls import reverse, reverse_lazy | ||
|
||
|
||
class MaintenanceMiddleware(object): | ||
""" | ||
This middleware allows us to turn on "Maintenance Mode". Toggle `MAINTENANCE_MODE` to True in | ||
`process_view` to redirect all requests in the app to the maintenance holding page. | ||
""" | ||
|
||
def __init__(self, get_response): | ||
self.get_response = get_response | ||
|
||
def __call__(self, request): | ||
response = self.get_response(request) | ||
return response | ||
|
||
def process_view(self, request, callback, callback_args, callback_kwargs): | ||
MAINTENANCE_MODE = False | ||
|
||
if MAINTENANCE_MODE and not request.path.startswith(reverse("maintenance")): | ||
return HttpResponseRedirect(reverse_lazy("maintenance")) | ||
|
||
if not MAINTENANCE_MODE and request.path.startswith(reverse("maintenance")): | ||
return HttpResponseRedirect(reverse_lazy("home")) | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{% load static %} | ||
{% load app_tags %} | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Code For Life - maintenance</title> | ||
<link rel="stylesheet" type="text/css" href="{% static 'portal.css' %}"> | ||
<link href="https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500&display=swap" rel="stylesheet"> | ||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap" rel="stylesheet"> | ||
<link rel="shortcut icon" href="{% static 'portal/img/favicon.ico' %}" type="image/x-icon"> | ||
<link rel="icon" href="{% static 'portal/img/favicon.ico' %}" type="image/x-icon"> | ||
</head> | ||
<body> | ||
<div class="content-footer-wrapper"> | ||
<div id="contentWrapper"> | ||
{% block topBar %} | ||
{% include 'portal/partials/header.html' %} | ||
{% endblock topBar %} | ||
<div class="content"> | ||
<div class="error-page background container"> | ||
<div class="row mx-0 d-flex justify-content-between"> | ||
<div class="flex-grow-1"> | ||
<h2>Works in progress!</h2> | ||
<h5>Apologies! Dee is working on something important.</h5> | ||
<p>The website is temporarily unavailable.</p> | ||
</div> | ||
<img title="Dee" alt="Dee" src="{% static 'portal/img/dee.png' %}"/> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters