aboutsummaryrefslogtreecommitdiff
path: root/webmentions_ssg/views/admin.py
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--webmentions_ssg/views/admin.py78
1 files changed, 39 insertions, 39 deletions
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/<uuid:identifier>/delete")
+@webmentions_bp.post("/received/<uuid:webmention_uuid>/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/<uuid:identifier>/reverify")
+@webmentions_bp.post("/received/<uuid:webmention_uuid>/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/<uuid:source_identifier>")
+@webmentions_bp.route("/sources/<uuid:source_uuid>")
@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/<uuid:source_identifier>/<uuid:webmention_identifier>/resend")
+@webmentions_bp.post("/sources/<uuid:source_uuid>/<uuid:webmention_uuid>/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))