From 509d93b2976e353d29441a7a7b7e78ca466dc4fd Mon Sep 17 00:00:00 2001 From: Dennis Fink Date: Sun, 15 Nov 2026 20:42:20 +0100 Subject: refactor(core)!: standardize application terminology Rename configuration keys, task helpers, forms, network utilities, and view endpoints to make their responsibilities and domains more explicit. Align source-management routes and templates with the new terminology and rename the target-matching module and related task abstractions consistently. BREAKING CHANGE: configuration keys have been renamed and sent-source routes move from `/sent` to `/sources`, with corresponding blueprint endpoint changes. --- webmentions_ssg/views/admin.py | 78 +++++++++++++++++++++--------------------- 1 file changed, 39 insertions(+), 39 deletions(-) (limited to 'webmentions_ssg/views/admin.py') diff --git a/webmentions_ssg/views/admin.py b/webmentions_ssg/views/admin.py index 2ccd92a..9b7c418 100644 --- a/webmentions_ssg/views/admin.py +++ b/webmentions_ssg/views/admin.py @@ -19,12 +19,12 @@ from ..models import ReceivedWebmention, SentWebmention, Source from ..tasks.receiver import verify_webmention from ..tasks.scanner import manual_scan_sources from ..tasks.sender import send_webmention -from .blueprint import root_page +from .blueprint import webmentions_bp -@root_page.route("/received") +@webmentions_bp.route("/received") @login_required -def received() -> ResponseReturnValue: +def received_list() -> ResponseReturnValue: """Display received Webmentions. :returns: Rendered page containing the paginated received Webmentions. @@ -38,22 +38,22 @@ def received() -> ResponseReturnValue: "received.html", title="Received Webmentions", webmentions=webmentions, - action_form=forms.AdminActionForm(), + action_form=forms.ConfirmActionForm(), ) -@root_page.post("/received//delete") +@webmentions_bp.post("/received//delete") @login_required -def delete_received_webmention(identifier: uuid.UUID) -> ResponseReturnValue: +def delete_received_webmention(webmention_uuid: uuid.UUID) -> ResponseReturnValue: """Delete a received Webmention. - :param identifier: Identifier of the Webmention to delete. + :param webmention_uuid: UUID of the Webmention to delete. :returns: Redirect response to the received Webmentions view. """ - if not forms.AdminActionForm().validate_on_submit(): + if not forms.ConfirmActionForm().validate_on_submit(): abort(HTTPStatus.BAD_REQUEST) - webmention = db.get_or_404(ReceivedWebmention, identifier) + webmention = db.get_or_404(ReceivedWebmention, webmention_uuid) db.session.delete(webmention) db.session.commit() @@ -61,41 +61,41 @@ def delete_received_webmention(identifier: uuid.UUID) -> ResponseReturnValue: flash(f"Webmention {webmention.uuid} deleted.", "success") return redirect( - url_for("root.received", page=request.args.get("page", 1, type=int)) + url_for("webmentions.received_list", page=request.args.get("page", 1, type=int)) ) -@root_page.post("/received//reverify") +@webmentions_bp.post("/received//reverify") @login_required -def reverify_received_webmention(identifier: uuid.UUID) -> ResponseReturnValue: +def reverify_received_webmention(webmention_uuid: uuid.UUID) -> ResponseReturnValue: """Queue a received Webmention for reverification. The Webmention status is reset before a new verification task is queued. - :param identifier: Identifier of the Webmention to reverify. + :param webmention_uuid: UUID of the Webmention to reverify. :returns: Redirect response to the received Webmentions view. """ - if not forms.AdminActionForm().validate_on_submit(): + if not forms.ConfirmActionForm().validate_on_submit(): abort(HTTPStatus.BAD_REQUEST) - webmention = db.get_or_404(ReceivedWebmention, identifier) + webmention = db.get_or_404(ReceivedWebmention, webmention_uuid) webmention.reset_for_verification() db.session.commit() - verify_webmention(identifier) + verify_webmention(webmention_uuid) flash(f"Webmention {webmention.uuid} queued for reverification.", "success") return redirect( - url_for("root.received", page=request.args.get("page", 1, type=int)) + url_for("webmentions.received_list", page=request.args.get("page", 1, type=int)) ) -@root_page.route("/sent") +@webmentions_bp.route("/sources") @login_required -def sent() -> ResponseReturnValue: +def source_list() -> ResponseReturnValue: """Display sources with sent Webmentions. :returns: Rendered page containing the paginated source list. @@ -110,35 +110,35 @@ def sent() -> ResponseReturnValue: "sent.html", title="Sent Webmentions", sources=sources, - action_form=forms.AdminActionForm(), + action_form=forms.ConfirmActionForm(), ) -@root_page.post("/sent/rescan") +@webmentions_bp.post("/sources/rescan") @login_required -def rescan_sent_sources() -> ResponseReturnValue: +def rescan_sources() -> ResponseReturnValue: """Queue a manual scan of sent Webmention sources. :returns: Redirect response to the sent Webmentions view. """ - if not forms.AdminActionForm().validate_on_submit(): + if not forms.ConfirmActionForm().validate_on_submit(): abort(HTTPStatus.BAD_REQUEST) manual_scan_sources() flash("Source rescan queued.", "success") - return redirect(url_for("root.sent")) + return redirect(url_for("webmentions.source_list")) -@root_page.route("/sent/") +@webmentions_bp.route("/sources/") @login_required -def sent_source(source_identifier: uuid.UUID) -> ResponseReturnValue: +def source_detail(source_uuid: uuid.UUID) -> ResponseReturnValue: """Display the sent Webmentions associated with a source. - :param source_identifier: Identifier of the source to display. + :param source_uuid: UUID of the source to display. :returns: Rendered source details page. """ - source = db.get_or_404(Source, source_identifier) + source = db.get_or_404(Source, source_uuid) webmentions = db.paginate( sa.select(SentWebmention) @@ -152,14 +152,14 @@ def sent_source(source_identifier: uuid.UUID) -> ResponseReturnValue: title="Sent Webmentions", source=source, webmentions=webmentions, - action_form=forms.AdminActionForm(), + action_form=forms.ConfirmActionForm(), ) -@root_page.post("/sent///resend") +@webmentions_bp.post("/sources///resend") @login_required -def resend_sent_webmention( - source_identifier: uuid.UUID, webmention_identifier: uuid.UUID +def resend_webmention( + source_uuid: uuid.UUID, webmention_uuid: uuid.UUID ) -> ResponseReturnValue: """Queue an outgoing Webmention to be sent again. @@ -168,16 +168,16 @@ def resend_sent_webmention( successful-send fields are preserved, while result fields from the previous attempt are cleared. - :param source_identifier: Identifier of the source owning the Webmention. - :param webmention_identifier: Identifier of the sent Webmention to resend. + :param source_uuid: UUID of the source owning the Webmention. + :param webmention_uuid: UUID of the sent Webmention to resend. :returns: Redirect response to the source details view. """ - if not forms.AdminActionForm().validate_on_submit(): + if not forms.ConfirmActionForm().validate_on_submit(): abort(HTTPStatus.BAD_REQUEST) - webmention = db.get_or_404(SentWebmention, webmention_identifier) + webmention = db.get_or_404(SentWebmention, webmention_uuid) - if webmention.source_id != source_identifier: + if webmention.source_id != source_uuid: abort(HTTPStatus.NOT_FOUND) # Requeue the existing desired revision instead of inventing a new source @@ -187,8 +187,8 @@ def resend_sent_webmention( db.session.commit() - send_webmention(webmention_identifier) + send_webmention(webmention_uuid) flash(f"Webmention {webmention.uuid} queued for resend.", "success") - return redirect(url_for("root.sent_source", source_identifier=source_identifier)) + return redirect(url_for("webmentions.source_detail", source_uuid=source_uuid)) -- cgit v1.3.1