From 2bf9b4a8c8419054a48036a1746c2c496062853e Mon Sep 17 00:00:00 2001 From: rra Date: Tue, 16 Apr 2024 12:10:24 +0200 Subject: [PATCH] instance contact email interface, forms and display on about page --- app/admin/forms.py | 3 ++- app/admin/routes.py | 1 + app/templates/about.html | 8 ++++---- app/templates/admin/site.html | 1 + 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/app/admin/forms.py b/app/admin/forms.py index 43c48e51..59abaac6 100644 --- a/app/admin/forms.py +++ b/app/admin/forms.py @@ -1,7 +1,7 @@ from flask_wtf import FlaskForm from flask_wtf.file import FileRequired, FileAllowed from sqlalchemy import func -from wtforms import StringField, PasswordField, SubmitField, HiddenField, BooleanField, TextAreaField, SelectField, \ +from wtforms import StringField, PasswordField, SubmitField, EmailField, HiddenField, BooleanField, TextAreaField, SelectField, \ FileField, IntegerField from wtforms.validators import ValidationError, DataRequired, Email, EqualTo, Length, Optional from flask_babel import _, lazy_gettext as _l @@ -17,6 +17,7 @@ class SiteProfileForm(FlaskForm): ]) sidebar = TextAreaField(_l('Sidebar')) legal_information = TextAreaField(_l('Legal information')) + contact_email = EmailField(_l('General instance contact email address'), validators=[Email(), DataRequired(), Length(min=5, max=255)]) submit = SubmitField(_l('Save')) diff --git a/app/admin/routes.py b/app/admin/routes.py index eba8418e..2d3d2030 100644 --- a/app/admin/routes.py +++ b/app/admin/routes.py @@ -48,6 +48,7 @@ def admin_site(): site.sidebar = form.sidebar.data site.legal_information = form.legal_information.data site.updated = utcnow() + site.contact_email = form.contact_email.data if site.id is None: db.session.add(site) db.session.commit() diff --git a/app/templates/about.html b/app/templates/about.html index ed679ffa..a7a7c018 100644 --- a/app/templates/about.html +++ b/app/templates/about.html @@ -13,13 +13,13 @@

This instance is administerred by {% for admin in admins %}{{ admin.user_name }}{{ ", " if not loop.last }}{% endfor %}.

It is moderated by {% for s in staff %}{{ s.user_name }}{{ ", " if not loop.last }}{% endfor %}.

Contact

-

$PLACEHOLDER_EMAIL

+

{{g.site.contact_email | safe }}

About Us

-

{{g.site.description | safe}}

-

{{g.site.sidebar}}

+

{{g.site.description | safe }}

+

{{g.site.sidebar | safe }}

{% if g.site.legal_information %}

Legal Information

-

{{g.site.legal_information}}

+

{{g.site.legal_information | safe }}

Our Privacy Policy

{% endif %} diff --git a/app/templates/admin/site.html b/app/templates/admin/site.html index 31bfa7be..57496d52 100644 --- a/app/templates/admin/site.html +++ b/app/templates/admin/site.html @@ -20,6 +20,7 @@

HTML is allowed in this field.

{{ render_field(form.legal_information) }}

HTML is allowed in this field.

+ {{ render_field(form.contact_email) }} {{ render_field(form.submit) }}