From 4efb2a543a274b893f4b3bf8bc3cc10e04ab5620 Mon Sep 17 00:00:00 2001 From: moson Date: Sun, 10 Sep 2023 08:49:59 +0200 Subject: [PATCH] housekeep: TU rename - /tu routes Change /tu to /package-maintainer Signed-off-by: moson --- aurweb/routers/package_maintainer.py | 22 ++--- aurweb/scripts/notify.py | 2 +- .../{tu => package-maintainer}/index.html | 6 +- .../{tu => package-maintainer}/show.html | 6 +- templates/partials/archdev-navbar.html | 2 +- .../last_votes.html | 2 +- .../proposal/details.html | 0 .../proposal/form.html | 2 +- .../proposal/voters.html | 0 .../{tu => package-maintainer}/proposals.html | 2 +- test/test_notify.py | 4 +- test/test_trusted_user_routes.py | 80 ++++++++++--------- test/test_tuvotereminder.py | 2 +- 13 files changed, 68 insertions(+), 62 deletions(-) rename templates/{tu => package-maintainer}/index.html (87%) rename templates/{tu => package-maintainer}/show.html (61%) rename templates/partials/{tu => package-maintainer}/last_votes.html (92%) rename templates/partials/{tu => package-maintainer}/proposal/details.html (100%) rename templates/partials/{tu => package-maintainer}/proposal/form.html (84%) rename templates/partials/{tu => package-maintainer}/proposal/voters.html (100%) rename templates/partials/{tu => package-maintainer}/proposals.html (97%) diff --git a/aurweb/routers/package_maintainer.py b/aurweb/routers/package_maintainer.py index b582edde..f358b453 100644 --- a/aurweb/routers/package_maintainer.py +++ b/aurweb/routers/package_maintainer.py @@ -52,7 +52,7 @@ def populate_package_maintainer_counts(context: dict[str, Any]) -> None: context["active_package_maintainer_count"] = active_pm_query.count() -@router.get("/tu") +@router.get("/package-maintainer") @requires_auth async def package_maintainer( request: Request, @@ -141,7 +141,7 @@ async def package_maintainer( "pby": past_by, } - return render_template(request, "tu/index.html", context) + return render_template(request, "package-maintainer/index.html", context) def render_proposal( @@ -176,14 +176,16 @@ def render_proposal( context["vote"] = vote context["has_voted"] = vote is not None - return render_template(request, "tu/show.html", context, status_code=status_code) + return render_template( + request, "package-maintainer/show.html", context, status_code=status_code + ) -@router.get("/tu/{proposal}") +@router.get("/package-maintainer/{proposal}") @requires_auth async def package_maintainer_proposal(request: Request, proposal: int): if not request.user.has_credential(creds.PM_LIST_VOTES): - return RedirectResponse("/tu", status_code=HTTPStatus.SEE_OTHER) + return RedirectResponse("/package-maintainer", status_code=HTTPStatus.SEE_OTHER) context = await make_variable_context(request, "Package Maintainer") proposal = int(proposal) @@ -221,14 +223,14 @@ async def package_maintainer_proposal(request: Request, proposal: int): @db.async_retry_deadlock -@router.post("/tu/{proposal}") +@router.post("/package-maintainer/{proposal}") @handle_form_exceptions @requires_auth async def package_maintainer_proposal_post( request: Request, proposal: int, decision: str = Form(...) ): if not request.user.has_credential(creds.PM_LIST_VOTES): - return RedirectResponse("/tu", status_code=HTTPStatus.SEE_OTHER) + return RedirectResponse("/package-maintainer", status_code=HTTPStatus.SEE_OTHER) context = await make_variable_context(request, "Package Maintainer") proposal = int(proposal) # Make sure it's an int. @@ -292,7 +294,7 @@ async def package_maintainer_addvote( request: Request, user: str = str(), type: str = "add_pm", agenda: str = str() ): if not request.user.has_credential(creds.PM_ADD_VOTE): - return RedirectResponse("/tu", status_code=HTTPStatus.SEE_OTHER) + return RedirectResponse("/package-maintainer", status_code=HTTPStatus.SEE_OTHER) context = await make_variable_context(request, "Add Proposal") @@ -318,7 +320,7 @@ async def package_maintainer_addvote_post( agenda: str = Form(default=str()), ): if not request.user.has_credential(creds.PM_ADD_VOTE): - return RedirectResponse("/tu", status_code=HTTPStatus.SEE_OTHER) + return RedirectResponse("/package-maintainer", status_code=HTTPStatus.SEE_OTHER) # Build a context. context = await make_variable_context(request, "Add Proposal") @@ -394,5 +396,5 @@ async def package_maintainer_addvote_post( ) # Redirect to the new proposal. - endpoint = f"/tu/{voteinfo.ID}" + endpoint = f"/package-maintainer/{voteinfo.ID}" return RedirectResponse(endpoint, status_code=HTTPStatus.SEE_OTHER) diff --git a/aurweb/scripts/notify.py b/aurweb/scripts/notify.py index 71757abf..232df78c 100755 --- a/aurweb/scripts/notify.py +++ b/aurweb/scripts/notify.py @@ -780,7 +780,7 @@ class TUVoteReminderNotification(Notification): ).format(id=self._vote_id) def get_refs(self): - return (aur_location + "/tu/?id=" + str(self._vote_id),) + return (aur_location + "/package-maintainer/?id=" + str(self._vote_id),) def main(): diff --git a/templates/tu/index.html b/templates/package-maintainer/index.html similarity index 87% rename from templates/tu/index.html rename to templates/package-maintainer/index.html index cdb4488f..edb32ca6 100644 --- a/templates/tu/index.html +++ b/templates/package-maintainer/index.html @@ -28,7 +28,7 @@ off = current_off, by = current_by %} - {% include "partials/tu/proposals.html" %} + {% include "partials/package-maintainer/proposals.html" %} {% endwith %} {% @@ -42,10 +42,10 @@ off = past_off, by = past_by %} - {% include "partials/tu/proposals.html" %} + {% include "partials/package-maintainer/proposals.html" %} {% endwith %} {% with title = "Last Votes by Package Maintainer", votes = last_votes_by_pm %} - {% include "partials/tu/last_votes.html" %} + {% include "partials/package-maintainer/last_votes.html" %} {% endwith %} {% endblock %} diff --git a/templates/tu/show.html b/templates/package-maintainer/show.html similarity index 61% rename from templates/tu/show.html rename to templates/package-maintainer/show.html index f4214018..e6f24b5b 100644 --- a/templates/tu/show.html +++ b/templates/package-maintainer/show.html @@ -2,12 +2,12 @@ {% block pageContent %}
- {% include "partials/tu/proposal/details.html" %} + {% include "partials/package-maintainer/proposal/details.html" %}
{% if utcnow >= voteinfo.End %}
- {% include "partials/tu/proposal/voters.html" %} + {% include "partials/package-maintainer/proposal/voters.html" %}
{% endif %} @@ -15,7 +15,7 @@ {% if error %} {{ error | tr }} {% else %} - {% include "partials/tu/proposal/form.html" %} + {% include "partials/package-maintainer/proposal/form.html" %} {% endif %} {% endblock %} diff --git a/templates/partials/archdev-navbar.html b/templates/partials/archdev-navbar.html index d1d66c79..ea67b1ca 100644 --- a/templates/partials/archdev-navbar.html +++ b/templates/partials/archdev-navbar.html @@ -39,7 +39,7 @@ {# Only CRED_PM_LIST_VOTES privileged users see Package Maintainer #} {% if request.user.has_credential(creds.PM_LIST_VOTES) %}
  • - {% trans %}Package Maintainer{% endtrans %} + {% trans %}Package Maintainer{% endtrans %}
  • {% endif %} diff --git a/templates/partials/tu/last_votes.html b/templates/partials/package-maintainer/last_votes.html similarity index 92% rename from templates/partials/tu/last_votes.html rename to templates/partials/package-maintainer/last_votes.html index 30d620d4..4f30d9ff 100644 --- a/templates/partials/tu/last_votes.html +++ b/templates/partials/package-maintainer/last_votes.html @@ -24,7 +24,7 @@ - + {{ vote.LastVote }} diff --git a/templates/partials/tu/proposal/details.html b/templates/partials/package-maintainer/proposal/details.html similarity index 100% rename from templates/partials/tu/proposal/details.html rename to templates/partials/package-maintainer/proposal/details.html diff --git a/templates/partials/tu/proposal/form.html b/templates/partials/package-maintainer/proposal/form.html similarity index 84% rename from templates/partials/tu/proposal/form.html rename to templates/partials/package-maintainer/proposal/form.html index d783a622..e172b29d 100644 --- a/templates/partials/tu/proposal/form.html +++ b/templates/partials/package-maintainer/proposal/form.html @@ -1,4 +1,4 @@ -
    +