mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
feat(FastAPI): add /pkgbase/{name}/adopt (post)
Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
parent
72d6016da4
commit
305d077973
3 changed files with 65 additions and 4 deletions
|
@ -950,6 +950,23 @@ async def pkgbase_disown_post(request: Request, name: str,
|
|||
status_code=int(HTTPStatus.SEE_OTHER))
|
||||
|
||||
|
||||
@router.post("/pkgbase/{name}/adopt")
|
||||
@auth_required(True)
|
||||
async def pkgbase_adopt_post(request: Request, name: str):
|
||||
pkgbase = get_pkg_or_base(name, PackageBase)
|
||||
|
||||
has_cred = request.user.has_credential("CRED_PKGBASE_ADOPT")
|
||||
if has_cred or not pkgbase.Maintainer:
|
||||
# If the user has credentials, they'll adopt the package regardless
|
||||
# of maintainership. Otherwise, we'll promote the user to maintainer
|
||||
# if no maintainer currently exists.
|
||||
with db.begin():
|
||||
pkgbase.Maintainer = request.user
|
||||
|
||||
return RedirectResponse(f"/pkgbase/{name}",
|
||||
status_code=int(HTTPStatus.SEE_OTHER))
|
||||
|
||||
|
||||
@router.get("/pkgbase/{name}/delete")
|
||||
@auth_required(True)
|
||||
async def pkgbase_delete_get(request: Request, name: str):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue