From 6d6d079a3a99d3d3a922a640b6925eb2adf044de Mon Sep 17 00:00:00 2001 From: Dennis Fink Date: Tue, 17 Nov 2026 17:09:59 +0100 Subject: refactor(core)!: split forms and models by feature Replace monolithic form and model modules with focused packages for receiver, moderation, source, user, and shared validation concerns. Rename source policy concepts to domain moderation, including routes, models, tables, configuration, templates, and tests. BREAKING CHANGE: form and model import paths, moderation routes, and `SOURCE_ALLOWLIST_ENABLED` have changed; use `ALLOWLIST_ENABLED` and the new feature-specific modules. --- webmentions_ssg/forms/moderation.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 webmentions_ssg/forms/moderation.py (limited to 'webmentions_ssg/forms/moderation.py') diff --git a/webmentions_ssg/forms/moderation.py b/webmentions_ssg/forms/moderation.py new file mode 100644 index 0000000..5987d14 --- /dev/null +++ b/webmentions_ssg/forms/moderation.py @@ -0,0 +1,25 @@ +# SPDX-FileCopyrightText: 2026 Dennis Fink +# +# SPDX-License-Identifier: BSD-3-Clause + +"""Forms for managing domain allowlists and blocklists.""" + +from flask_wtf import FlaskForm +from wtforms import Field, StringField, SubmitField, ValidationError +from wtforms.validators import InputRequired + +from ..hostname import normalize_hostname + + +class ModerateDomainForm(FlaskForm): + """Add a source domain to the blocklist or allowlist.""" + + domain = StringField("Source domain", validators=[InputRequired()]) + submit = SubmitField("Add domain") + + def validate_domain(self, field: Field) -> None: + """Require a bare hostname and persist its canonical form.""" + try: + field.data = normalize_hostname(field.data) + except ValueError as exc: + raise ValidationError(str(exc)) from exc -- cgit v1.3.1