mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
fix(fastapi): pass request type's name to Request*Notification
Previously, we passed the straight up request type instance from SQLAlchemy and had a .title() function that was transparently treating the instance the same as the instance's Name in terms of notify.py's use of it. This commit removes that transparent behavior; it was not actually intended. Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
parent
3b28be1741
commit
b4092fe77d
2 changed files with 9 additions and 14 deletions
|
@ -17,14 +17,7 @@ class RequestType(Base):
|
||||||
|
|
||||||
def name_display(self) -> str:
|
def name_display(self) -> str:
|
||||||
""" Return the Name column with its first char capitalized. """
|
""" Return the Name column with its first char capitalized. """
|
||||||
name = self.Name
|
return self.Name.title()
|
||||||
return name[0].upper() + name[1:]
|
|
||||||
|
|
||||||
def title(self) -> str:
|
|
||||||
return self.name_display()
|
|
||||||
|
|
||||||
def __getitem__(self, n: int) -> str:
|
|
||||||
return self.Name[n]
|
|
||||||
|
|
||||||
|
|
||||||
DELETION_ID = db.query(RequestType, RequestType.Name == DELETION).first().ID
|
DELETION_ID = db.query(RequestType, RequestType.Name == DELETION).first().ID
|
||||||
|
|
|
@ -697,18 +697,20 @@ async def pkgbase_request_post(request: Request, name: str,
|
||||||
now = int(datetime.utcnow().timestamp())
|
now = int(datetime.utcnow().timestamp())
|
||||||
reqtype = db.query(models.RequestType).filter(
|
reqtype = db.query(models.RequestType).filter(
|
||||||
models.RequestType.Name == type).first()
|
models.RequestType.Name == type).first()
|
||||||
conn = db.ConnectionExecutor(db.get_engine().raw_connection())
|
|
||||||
notify_ = None
|
|
||||||
with db.begin():
|
with db.begin():
|
||||||
pkgreq = db.create(models.PackageRequest, RequestType=reqtype,
|
pkgreq = db.create(models.PackageRequest,
|
||||||
RequestTS=now, PackageBase=pkgbase,
|
RequestType=reqtype,
|
||||||
|
User=request.user,
|
||||||
|
RequestTS=now,
|
||||||
|
PackageBase=pkgbase,
|
||||||
PackageBaseName=pkgbase.Name,
|
PackageBaseName=pkgbase.Name,
|
||||||
MergeBaseName=merge_into, User=request.user,
|
MergeBaseName=merge_into,
|
||||||
Comments=comments, ClosureComment=str())
|
Comments=comments, ClosureComment=str())
|
||||||
|
|
||||||
# Prepare notification object.
|
# Prepare notification object.
|
||||||
|
conn = db.ConnectionExecutor(db.get_engine().raw_connection())
|
||||||
notify_ = notify.RequestOpenNotification(
|
notify_ = notify.RequestOpenNotification(
|
||||||
conn, request.user.ID, pkgreq.ID, reqtype,
|
conn, request.user.ID, pkgreq.ID, reqtype.Name,
|
||||||
pkgreq.PackageBase.ID, merge_into=merge_into or None)
|
pkgreq.PackageBase.ID, merge_into=merge_into or None)
|
||||||
|
|
||||||
# Send the notification now that we're out of the DB scope.
|
# Send the notification now that we're out of the DB scope.
|
||||||
|
|
Loading…
Add table
Reference in a new issue