mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
feat(FastAPI): allow reporters to cancel their own requests (1/2)
This change required a slight modification of how we handle the Requests page. It is now available to all users. This commit provides 1/2 of the implementation which actually satisfies this feature. 2/2 will contain the actual implementation of closures of requests, which will also allow users who created the request to decide to close it. Issue: https://gitlab.archlinux.org/archlinux/aurweb/-/issues/20 Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
parent
99482f9962
commit
1cf9420997
2 changed files with 27 additions and 10 deletions
|
@ -12,8 +12,7 @@ import aurweb.models.package_keyword
|
|||
import aurweb.packages.util
|
||||
|
||||
from aurweb import db, defaults, l10n
|
||||
from aurweb.auth import account_type_required, auth_required
|
||||
from aurweb.models.account_type import DEVELOPER, TRUSTED_USER, TRUSTED_USER_AND_DEV
|
||||
from aurweb.auth import auth_required
|
||||
from aurweb.models.license import License
|
||||
from aurweb.models.package import Package
|
||||
from aurweb.models.package_base import PackageBase
|
||||
|
@ -540,7 +539,6 @@ async def package_base_comaintainers_post(
|
|||
|
||||
|
||||
@router.get("/requests")
|
||||
@account_type_required({TRUSTED_USER, DEVELOPER, TRUSTED_USER_AND_DEV})
|
||||
@auth_required(True, redirect="/")
|
||||
async def requests(request: Request,
|
||||
O: int = Query(default=defaults.O),
|
||||
|
@ -556,6 +554,11 @@ async def requests(request: Request,
|
|||
User, PackageRequest.UsersID == User.ID
|
||||
).join(RequestType)
|
||||
|
||||
# If the request user is not elevated (TU or Dev), then
|
||||
# filter PackageRequests which are owned by the request user.
|
||||
if not request.user.is_elevated():
|
||||
query = query.filter(PackageRequest.UsersID == request.user.ID)
|
||||
|
||||
context["total"] = query.count()
|
||||
context["results"] = query.order_by(
|
||||
# Order primarily by the Status column being PENDING_ID,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue