[damned-lies/develop: 226/226] feat: add a warning message when not running in production
- From: Guillaume Bernard <gbernard src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [damned-lies/develop: 226/226] feat: add a warning message when not running in production
- Date: Mon, 5 Sep 2022 09:43:34 +0000 (UTC)
commit 1421ed3012451641fc6c12670cf8e945c02e5b58
Author: Guillaume Bernard <associations guillaume-bernard fr>
Date: Mon Sep 5 11:43:04 2022 +0200
feat: add a warning message when not running in production
.../production/configuration/local_settings.py.jinja2 | 6 ++++++
damnedlies/context_processors.py | 13 +++++++++++++
damnedlies/settings.py | 1 +
templates/base.html | 4 ++++
4 files changed, 24 insertions(+)
---
diff --git a/containers/production/configuration/local_settings.py.jinja2
b/containers/production/configuration/local_settings.py.jinja2
index e7ad3713..6748d546 100644
--- a/containers/production/configuration/local_settings.py.jinja2
+++ b/containers/production/configuration/local_settings.py.jinja2
@@ -69,3 +69,9 @@ FILE_UPLOAD_PERMISSIONS = 0o644
GITLAB_TOKEN = "$GITLAB_TOKEN"
VCS_HOME_REGEX = "gitlab\.gnome\.org"
+
+{% if kind == "production" %}
+RUNNING_PRODUCTION_SYSTEM = True
+{% else %}
+RUNNING_PRODUCTION_SYSTEM = False
+{% endif %}
diff --git a/damnedlies/context_processors.py b/damnedlies/context_processors.py
new file mode 100644
index 00000000..f612c7d2
--- /dev/null
+++ b/damnedlies/context_processors.py
@@ -0,0 +1,13 @@
+
+def running_integration_instance(request):
+ running_production_system = False
+ try:
+ from django.conf import settings
+
+ if settings.RUNNING_PRODUCTION_SYSTEM and isinstance(settings.RUNNING_PRODUCTION_SYSTEM, bool):
+ running_production_system = settings.RUNNING_PRODUCTION_SYSTEM
+ except (ImportError, AttributeError):
+ pass
+ return {
+ "RUNNING_PRODUCTION_SYSTEM": running_production_system,
+ }
diff --git a/damnedlies/settings.py b/damnedlies/settings.py
index a51f30e3..55ece015 100644
--- a/damnedlies/settings.py
+++ b/damnedlies/settings.py
@@ -110,6 +110,7 @@ TEMPLATES = [
# Added processors:
'django.template.context_processors.request',
'common.context_processors.utils',
+ 'damnedlies.context_processors.running_integration_instance',
],
'builtins': [
'django.templatetags.i18n',
diff --git a/templates/base.html b/templates/base.html
index 391b0390..93e408fb 100644
--- a/templates/base.html
+++ b/templates/base.html
@@ -68,6 +68,10 @@
</div>
</header>
+{% if RUNNING_PRODUCTION_SYSTEM is False %}
+ <p class="errornote">{% translate "This is a preproduction instance of GNOME Damned Lies. If you wish to
contribute to GNOME, please, check out the official GNOME Damned Lies application." %}</p>
+{% endif %}
+
<div class="clearfix"></div>
<div id="content" class="container gnome-content">
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]