mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
fix(fastapi): utilize auto_{orphan,deletion}_age
Didn't get this in when the initial request port went down; here it is. Auto-accept orphan requests when the package has been out of date for longer than auto_orphan_age. Auto-accept deletion requests by the package's maintainer if the package has been uploaded within auto_deletion_age seconds ago. Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
parent
a348cdaac3
commit
7f981b9ed7
3 changed files with 109 additions and 33 deletions
34
aurweb/packages/validate.py
Normal file
34
aurweb/packages/validate.py
Normal file
|
@ -0,0 +1,34 @@
|
|||
from typing import Any, Dict
|
||||
|
||||
from aurweb import db, models
|
||||
from aurweb.exceptions import ValidationError
|
||||
|
||||
|
||||
def request(pkgbase: models.PackageBase,
|
||||
type: str, comments: str, merge_into: str,
|
||||
context: Dict[str, Any]) -> None:
|
||||
if not comments:
|
||||
raise ValidationError(["The comment field must not be empty."])
|
||||
|
||||
if type == "merge":
|
||||
# Perform merge-related checks.
|
||||
if not merge_into:
|
||||
# TODO: This error needs to be translated.
|
||||
raise ValidationError(
|
||||
['The "Merge into" field must not be empty.'])
|
||||
|
||||
target = db.query(models.PackageBase).filter(
|
||||
models.PackageBase.Name == merge_into
|
||||
).first()
|
||||
if not target:
|
||||
# TODO: This error needs to be translated.
|
||||
raise ValidationError([
|
||||
"The package base you want to merge into does not exist."
|
||||
])
|
||||
|
||||
db.refresh(target)
|
||||
if target.ID == pkgbase.ID:
|
||||
# TODO: This error needs to be translated.
|
||||
raise ValidationError([
|
||||
"You cannot merge a package base into itself."
|
||||
])
|
Loading…
Add table
Add a link
Reference in a new issue