mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
RequestType: add name_display() and record constants
Just like some of the other tables, we have some constant records that we use to denote types of things. This commit adds constants which correlate with these record constants. Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
parent
eb8ea53a44
commit
5bd3a7bbab
2 changed files with 28 additions and 2 deletions
|
@ -1,7 +1,12 @@
|
|||
from sqlalchemy import Column, Integer
|
||||
|
||||
from aurweb import db
|
||||
from aurweb.models.declarative import Base
|
||||
|
||||
DELETION = "deletion"
|
||||
ORPHAN = "orphan"
|
||||
MERGE = "merge"
|
||||
|
||||
|
||||
class RequestType(Base):
|
||||
__tablename__ = "RequestTypes"
|
||||
|
@ -9,3 +14,13 @@ class RequestType(Base):
|
|||
ID = Column(Integer, primary_key=True)
|
||||
|
||||
__mapper_args__ = {"primary_key": [ID]}
|
||||
|
||||
def name_display(self) -> str:
|
||||
""" Return the Name column with its first char capitalized. """
|
||||
name = self.Name
|
||||
return name[0].upper() + name[1:]
|
||||
|
||||
|
||||
DELETION_ID = db.query(RequestType, RequestType.Name == DELETION).first().ID
|
||||
ORPHAN_ID = db.query(RequestType, RequestType.Name == ORPHAN).first().ID
|
||||
MERGE_ID = db.query(RequestType, RequestType.Name == MERGE).first().ID
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue