From 8ec35babe87ff8139ec23cc10b858b7481f132db Mon Sep 17 00:00:00 2001 From: Dennis Fink Date: Thu, 19 Nov 2026 18:15:34 +0100 Subject: refactor(sender)!: align sent Webmention terminology Rename source-list forms, views, helpers, and tests around the Sent Webmentions UI while keeping source documents as the grouping model. BREAKING CHANGE: authenticated outgoing routes move from `/sources` to `/sent`, with corresponding blueprint endpoint and Python module renames. --- webmentions_ssg/forms/sent.py | 81 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 webmentions_ssg/forms/sent.py (limited to 'webmentions_ssg/forms/sent.py') diff --git a/webmentions_ssg/forms/sent.py b/webmentions_ssg/forms/sent.py new file mode 100644 index 0000000..65a2708 --- /dev/null +++ b/webmentions_ssg/forms/sent.py @@ -0,0 +1,81 @@ +# SPDX-FileCopyrightText: 2026 Dennis Fink +# +# SPDX-License-Identifier: BSD-3-Clause + +"""Filters for the sent Webmentions page.""" + +from flask import current_app +from flask_wtf import FlaskForm +from wtforms import ( + DateField, + HiddenField, + IntegerField, + SearchField, + SelectField, + ValidationError, +) +from wtforms.validators import AnyOf, NumberRange, Optional + +from .validators import CanonicalDate + +SENT_STATUS_CHOICES = { + "": "All source documents", + "failing": "Failing sends", + "retrying": "Awaiting retry", + "deleted": "Deleted source documents", +} + + +def default_sent_page_size() -> int: + """Use 25 rows unless the configured maximum is lower.""" + return min(25, current_app.config["SOURCES_MAX_PAGE_SIZE"]) + + +class SentFilterForm(FlaskForm): + """GET filters for sent Webmentions grouped by source document.""" + + status = SelectField("Status", choices=SENT_STATUS_CHOICES, default="") + q = SearchField("Path or URL") + date_from = DateField( + "Last seen from (UTC)", validators=[Optional(), CanonicalDate()] + ) + date_to = DateField("Last seen to (UTC)", validators=[Optional(), CanonicalDate()]) + sort = HiddenField( + default="last_seen", + validators=[ + AnyOf( + ( + "path", + "url", + "webmentions", + "revision", + "created", + "last_seen", + "status", + ) + ) + ], + ) + order = HiddenField(default="desc", validators=[AnyOf(("asc", "desc"))]) + per_page = IntegerField( + "Rows per page", + default=default_sent_page_size, + validators=[NumberRange(min=1)], + ) + + def validate_per_page(self, field: IntegerField) -> None: + """Enforce the deployment's maximum source-document page size.""" + if ( + field.data is not None + and field.data > current_app.config["SOURCES_MAX_PAGE_SIZE"] + ): + raise ValidationError("Rows per page exceeds the configured maximum.") + + def validate_date_to(self, field: DateField) -> None: + """Require an end date on or after the start date.""" + if ( + self.date_from.data is not None + and field.data is not None + and field.data < self.date_from.data + ): + raise ValidationError("End date must be on or after start date.") -- cgit v1.3.1