diff --git a/aurweb/pkgbase/actions.py b/aurweb/pkgbase/actions.py index 46609f89..27143d51 100644 --- a/aurweb/pkgbase/actions.py +++ b/aurweb/pkgbase/actions.py @@ -50,6 +50,12 @@ def pkgbase_disown_instance(request: Request, pkgbase: PackageBase) -> None: notifs = [notify.DisownNotification(disowner.ID, pkgbase.ID)] is_maint = disowner == pkgbase.Maintainer + + comaint = pkgbase.comaintainers.filter( + PackageComaintainer.User == disowner + ).one_or_none() + is_comaint = comaint is not None + if is_maint: with db.begin(): # Comaintainer with the lowest Priority value; next-in-line. @@ -63,6 +69,11 @@ def pkgbase_disown_instance(request: Request, pkgbase: PackageBase) -> None: else: # Otherwise, just orphan the package completely. pkgbase.Maintainer = None + elif is_comaint: + # This disown request is from a Comaintainer + with db.begin(): + notif = pkgbaseutil.remove_comaintainer(comaint) + notifs.append(notif) elif request.user.has_credential(creds.PKGBASE_DISOWN): # Otherwise, the request user performing this disownage is a # Trusted User and we treat it like a standard orphan request. diff --git a/aurweb/routers/pkgbase.py b/aurweb/routers/pkgbase.py index c735f474..1f09cfc8 100644 --- a/aurweb/routers/pkgbase.py +++ b/aurweb/routers/pkgbase.py @@ -545,15 +545,18 @@ async def pkgbase_disown_get(request: Request, name: str, next: str = Query(default=str())): pkgbase = get_pkg_or_base(name, PackageBase) + comaints = {c.User for c in pkgbase.comaintainers} + approved = [pkgbase.Maintainer] + list(comaints) has_cred = request.user.has_credential(creds.PKGBASE_DISOWN, - approved=[pkgbase.Maintainer]) + approved=approved) if not has_cred: - return RedirectResponse(f"/pkgbase/{name}", - HTTPStatus.SEE_OTHER) + return RedirectResponse(f"/pkgbase/{name}", HTTPStatus.SEE_OTHER) context = templates.make_context(request, "Disown Package") context["pkgbase"] = pkgbase context["next"] = next or "/pkgbase/{name}" + context["is_maint"] = request.user == pkgbase.Maintainer + context["is_comaint"] = request.user in comaints return render_template(request, "pkgbase/disown.html", context) @@ -566,8 +569,10 @@ async def pkgbase_disown_post(request: Request, name: str, next: str = Form(default=str())): pkgbase = get_pkg_or_base(name, PackageBase) + comaints = {c.User for c in pkgbase.comaintainers} + approved = [pkgbase.Maintainer] + list(comaints) has_cred = request.user.has_credential(creds.PKGBASE_DISOWN, - approved=[pkgbase.Maintainer]) + approved=approved) if not has_cred: return RedirectResponse(f"/pkgbase/{name}", HTTPStatus.SEE_OTHER) @@ -580,8 +585,9 @@ async def pkgbase_disown_post(request: Request, name: str, return render_template(request, "pkgbase/disown.html", context, status_code=HTTPStatus.BAD_REQUEST) - with db.begin(): - update_closure_comment(pkgbase, ORPHAN_ID, comments) + if request.user != pkgbase.Maintainer and request.user not in comaints: + with db.begin(): + update_closure_comment(pkgbase, ORPHAN_ID, comments) try: actions.pkgbase_disown_instance(request, pkgbase) @@ -862,7 +868,6 @@ async def pkgbase_merge_post(request: Request, name: str, comments: str = Form(default=str()), confirm: bool = Form(default=False), next: str = Form(default=str())): - pkgbase = get_pkg_or_base(name, PackageBase) context = await make_variable_context(request, "Package Merging") context["pkgbase"] = pkgbase diff --git a/templates/partials/packages/actions.html b/templates/partials/packages/actions.html index 2144b07a..fa8c994f 100644 --- a/templates/partials/packages/actions.html +++ b/templates/partials/packages/actions.html @@ -131,7 +131,7 @@ /> - {% elif request.user.has_credential(creds.PKGBASE_DISOWN, approved=[pkgbase.Maintainer]) %} + {% elif request.user.has_credential(creds.PKGBASE_DISOWN, approved=[pkgbase.Maintainer] + comaintainers) %}
  • {{ "Disown Package" | tr }} diff --git a/templates/pkgbase/disown.html b/templates/pkgbase/disown.html index 3cc7988d..1aedde4f 100644 --- a/templates/pkgbase/disown.html +++ b/templates/pkgbase/disown.html @@ -27,14 +27,16 @@ {% endfor %} -

    - {{ - "This action will close any pending package requests " - "related to it. If %sComments%s are omitted, a closure " - "comment will be autogenerated." - | tr | format("", "") | safe - }} -

    + {% if not is_maint and not is_comaint %} +

    + {{ + "This action will close any pending package requests " + "related to it. If %sComments%s are omitted, a closure " + "comment will be autogenerated." + | tr | format("", "") | safe + }} +

    + {% endif %}

    {{ @@ -47,14 +49,18 @@

    -

    - - -

    + {% if not is_maint and not is_comaint %} +

    + + +

    + {% else %} + + {% endif %}