aboutsummaryrefslogtreecommitdiff
path: root/webmentions_ssg/forms/sources.py
diff options
context:
space:
mode:
authorDennis Fink2026-11-19 18:15:34 +0100
committerDennis Fink2026-11-19 18:15:34 +0100
commit8ec35babe87ff8139ec23cc10b858b7481f132db (patch)
treeb1e2b2507abba25b570a32e7274b6c0158eac653 /webmentions_ssg/forms/sources.py
parent45d3d3fde75173dfbf27e08aae8501842a9511dd (diff)
downloadwebmentions-ssg-8ec35babe87ff8139ec23cc10b858b7481f132db.tar.gz
webmentions-ssg-8ec35babe87ff8139ec23cc10b858b7481f132db.zip
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.
Diffstat (limited to 'webmentions_ssg/forms/sources.py')
-rw-r--r--webmentions_ssg/forms/sources.py81
1 files changed, 0 insertions, 81 deletions
diff --git a/webmentions_ssg/forms/sources.py b/webmentions_ssg/forms/sources.py
deleted file mode 100644
index 04afe77..0000000
--- a/webmentions_ssg/forms/sources.py
+++ /dev/null
@@ -1,81 +0,0 @@
-# SPDX-FileCopyrightText: 2026 Dennis Fink <me+coding@dennisfink.me>
-#
-# SPDX-License-Identifier: BSD-3-Clause
-
-"""Source document filtering form."""
-
-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
-
-SOURCE_STATUS_CHOICES = {
- "": "All sources",
- "failing": "Failing sends",
- "retrying": "Awaiting retry",
- "deleted": "Deleted sources",
-}
-
-
-def default_source_page_size() -> int:
- """Use 25 rows unless the configured maximum is lower."""
- return min(25, current_app.config["SOURCES_MAX_PAGE_SIZE"])
-
-
-class SourceFilterForm(FlaskForm):
- """GET filters for the source document list."""
-
- status = SelectField("Status", choices=SOURCE_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_source_page_size,
- validators=[NumberRange(min=1)],
- )
-
- def validate_per_page(self, field: IntegerField) -> None:
- """Enforce the deployment's maximum source-list 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.")