From d01cd083d8d5db617e37468b5ac0e6c0c6cb5997 Mon Sep 17 00:00:00 2001 From: Oliver Falk Date: Mon, 24 Feb 2020 14:50:44 +0100 Subject: [PATCH] Add option to easily set maintenance page --- ivatar/urls.py | 17 +++++++++++++++-- templates/maintenance.html | 30 ++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 templates/maintenance.html diff --git a/ivatar/urls.py b/ivatar/urls.py index 618890a..39d44db 100644 --- a/ivatar/urls.py +++ b/ivatar/urls.py @@ -13,7 +13,6 @@ urlpatterns = [ # pylint: disable=invalid-name path('admin/', admin.site.urls), path('i18n/', include('django.conf.urls.i18n')), url('openid/', include('django_openid_auth.urls')), - url('accounts/', include('ivatar.ivataraccount.urls')), url('tools/', include('ivatar.tools.urls')), url( r'avatar/(?P\w{64})', @@ -36,7 +35,21 @@ urlpatterns = [ # pylint: disable=invalid-name url('privacy/', TemplateView.as_view(template_name='privacy.html'), name='privacy'), url('contact/', TemplateView.as_view(template_name='contact.html'), name='contact'), path('talk_to_us/', RedirectView.as_view(url='/contact'), name='talk_to_us'), - url('', TemplateView.as_view(template_name='home.html'), name='home'), ] +MAINTENANCE = False +try: + if settings.MAINTENANCE: + MAINTENANCE = True +except: + pass + +if MAINTENANCE: + urlpatterns.append(url('', TemplateView.as_view(template_name='maintenance.html'), name='home')) + urlpatterns.insert(3, url('accounts/', RedirectView.as_view(url='/'))) +else: + urlpatterns.append(url('', TemplateView.as_view(template_name='home.html'), name='home')) + urlpatterns.insert(3, url('accounts/', include('ivatar.ivataraccount.urls'))) + + urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) diff --git a/templates/maintenance.html b/templates/maintenance.html new file mode 100644 index 0000000..47e3dfa --- /dev/null +++ b/templates/maintenance.html @@ -0,0 +1,30 @@ +{% extends 'base_home.html' %} +{% load i18n %} +{% load static %} + +{% block title %}{% trans 'federated avatar hosting service' %}{% endblock %} + +{% block content %} + +
+
+
+

{{ site_name }}

+

{% trans 'freeing the web one face at a time' %}

+
+
+
+
+
+
+

{% trans 'Maintenance mode' %}

+ Libravatar is currently in maintenance mode.
+ Avatars are still served, but all write operations may result + in loss of these changes. +

+
+
+
+
+ +{% endblock %}