From 3de7837ac2edc388b83c395b853572396a531061 Mon Sep 17 00:00:00 2001 From: Martin Mahner Date: Sat, 7 Dec 2019 17:04:44 +0100 Subject: [PATCH] Extra context variables --- dpaste/apps.py | 12 ++++++++++++ dpaste/settings/base.py | 7 +++++-- dpaste/settings/tests.py | 2 +- dpaste/templates/dpaste/about.html | 2 ++ dpaste/templates/dpaste/includes/form.html | 4 +++- dpaste/templates/dpaste/new.html | 1 + 6 files changed, 24 insertions(+), 4 deletions(-) diff --git a/dpaste/apps.py b/dpaste/apps.py index 4e5ee3d..8ee32cc 100644 --- a/dpaste/apps.py +++ b/dpaste/apps.py @@ -26,6 +26,15 @@ class dpasteAppConfig(AppConfig): # """ EXTRA_HEAD_HTML = "" + # HTML content injected in the About page + EXTRA_POST_ABOUT = "" + + # HTML content injeted after the "New snippet" form + EXTRA_POST_NEW ="" + + # HTML content injected at the end of every form + EXTRA_POST_FORM = "" + # Integer. Length of the random slug for each new snippet. In the rare # case an existing slug is generated again, the length will increase by # one more character. @@ -629,4 +638,7 @@ class dpasteAppConfig(AppConfig): return { "dpaste_application_name": self.APPLICATION_NAME, "dpaste_extra_head_html": mark_safe(self.EXTRA_HEAD_HTML), + "dpaste_extra_post_about": mark_safe(self.EXTRA_POST_ABOUT), + "dpaste_extra_post_new": mark_safe(self.EXTRA_POST_NEW), + "dpaste_extra_post_form": mark_safe(self.EXTRA_POST_FORM), } diff --git a/dpaste/settings/base.py b/dpaste/settings/base.py index 95bfcdf..e2f7fdb 100644 --- a/dpaste/settings/base.py +++ b/dpaste/settings/base.py @@ -102,8 +102,11 @@ DATABASES = { # add that webserver right away. try: import django_webserver - INSTALLED_APPS.append('django_webserver') - sys.stdout.write(f'\nšŸš€ Production webserver installed. Will run on port {env("PORT")}\n') + + INSTALLED_APPS.append("django_webserver") + sys.stdout.write( + f'\nšŸš€ Production webserver installed. Will run on port {env("PORT")}\n' + ) except ImportError: pass diff --git a/dpaste/settings/tests.py b/dpaste/settings/tests.py index 7fdf578..311d931 100644 --- a/dpaste/settings/tests.py +++ b/dpaste/settings/tests.py @@ -1,6 +1,7 @@ """ Settings for the testsuite runs. """ +import django from .base import * # noqa SECRET_KEY = "test-key" @@ -11,6 +12,5 @@ DATABASES = { # Drop CSP middleware for Django 3.0 until it was fixed upstream # https://github.com/mozilla/django-csp/issues/129 -import django if django.get_version().startswith("3."): MIDDLEWARE.remove("csp.middleware.CSPMiddleware") diff --git a/dpaste/templates/dpaste/about.html b/dpaste/templates/dpaste/about.html index 60e5fe6..d580b60 100644 --- a/dpaste/templates/dpaste/about.html +++ b/dpaste/templates/dpaste/about.html @@ -20,5 +20,7 @@ on Github.

+ {{ dpaste_extra_post_about }} + {% endblock %} diff --git a/dpaste/templates/dpaste/includes/form.html b/dpaste/templates/dpaste/includes/form.html index bc063e1..734d091 100644 --- a/dpaste/templates/dpaste/includes/form.html +++ b/dpaste/templates/dpaste/includes/form.html @@ -31,10 +31,12 @@

- +

{{ form.content }}

+ + {{ dpaste_extra_post_form }} diff --git a/dpaste/templates/dpaste/new.html b/dpaste/templates/dpaste/new.html index 964a6a9..60e62f3 100644 --- a/dpaste/templates/dpaste/new.html +++ b/dpaste/templates/dpaste/new.html @@ -11,4 +11,5 @@ {% block page %} {% include "dpaste/includes/form.html" %} + {{ dpaste_extra_post_new }} {% endblock %}