diff options
author | Andrew Godwin | 2022-12-17 17:02:42 -0700 |
---|---|---|
committer | Andrew Godwin | 2022-12-17 17:02:54 -0700 |
commit | 77ef358fefc2d1172a8a8b38ad2ca1655633e776 (patch) | |
tree | 2bbc1f4cbfe9f383f7c2e10d228c0a93920fbed2 | |
parent | 03929e12ea7efe972417512f8588419d15b3ef3d (diff) | |
download | takahe-77ef358fefc2d1172a8a8b38ad2ca1655633e776.tar.gz takahe-77ef358fefc2d1172a8a8b38ad2ca1655633e776.tar.bz2 takahe-77ef358fefc2d1172a8a8b38ad2ca1655633e776.zip |
Allow markdown on signup text
-rw-r--r-- | templates/auth/signup.html | 2 | ||||
-rw-r--r-- | users/views/admin/settings.py | 2 | ||||
-rw-r--r-- | users/views/auth.py | 10 |
3 files changed, 12 insertions, 2 deletions
diff --git a/templates/auth/signup.html b/templates/auth/signup.html index 7924c0a..445f610 100644 --- a/templates/auth/signup.html +++ b/templates/auth/signup.html @@ -7,7 +7,7 @@ {% csrf_token %} <fieldset> <legend>Create An Account</legend> - {% if config.signup_text %}{{ config.signup_text|safe|linebreaks }}{% endif %} + {% if signup_text %}{{ signup_text }}{% endif %} {% if config.signup_allowed %} {% for field in form %} {% include "forms/_field.html" %} diff --git a/users/views/admin/settings.py b/users/views/admin/settings.py index f72c0bd..d87fb7e 100644 --- a/users/views/admin/settings.py +++ b/users/views/admin/settings.py @@ -77,7 +77,7 @@ class BasicSettings(AdminSettingsPage): }, "signup_text": { "title": "Signup Page Text", - "help_text": "Shown above the signup form", + "help_text": "Shown above the signup form.\nUse Markdown for formatting.", "display": "textarea", }, "restricted_usernames": { diff --git a/users/views/auth.py b/users/views/auth.py index 02c75e6..546aa49 100644 --- a/users/views/auth.py +++ b/users/views/auth.py @@ -1,9 +1,11 @@ +import markdown_it from django import forms from django.conf import settings from django.contrib.auth.forms import AuthenticationForm from django.contrib.auth.password_validation import validate_password from django.contrib.auth.views import LoginView, LogoutView from django.shortcuts import get_object_or_404, render +from django.utils.safestring import mark_safe from django.utils.translation import gettext_lazy as _ from django.views.generic import FormView @@ -110,6 +112,14 @@ class Signup(FormView): {"email": user.email}, ) + def get_context_data(self, **kwargs): + context = super().get_context_data(**kwargs) + if Config.system.signup_text: + context["signup_text"] = mark_safe( + markdown_it.MarkdownIt().render(Config.system.signup_text) + ) + return context + class TriggerReset(FormView): |