Extra context variables

This commit is contained in:
Martin Mahner 2019-12-07 17:04:44 +01:00
parent 101060e6e5
commit 3de7837ac2
6 changed files with 24 additions and 4 deletions

View file

@ -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),
}

View file

@ -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

View file

@ -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")

View file

@ -20,5 +20,7 @@
<a href="https://github.com/bartTC/dpaste">on Github</a>.
</p>
{{ dpaste_extra_post_about }}
</article>
{% endblock %}

View file

@ -36,5 +36,7 @@
<label for="{{ form.content.auto_id }}">{% trans "Content" %}</label>
{{ form.content }}
</p>
{{ dpaste_extra_post_form }}
</form>

View file

@ -11,4 +11,5 @@
{% block page %}
{% include "dpaste/includes/form.html" %}
{{ dpaste_extra_post_new }}
{% endblock %}