mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
We don't want to depend on the database to load up data about the models we define. We now leverage the existing `aurweb.schema` module for table definitions and set __table_args__["autoload"] to False. Signed-off-by: Kevin Morris <kevr@0cost.org>
25 lines
712 B
Python
25 lines
712 B
Python
from sqlalchemy.exc import IntegrityError
|
|
|
|
from aurweb import schema
|
|
from aurweb.models.declarative import Base
|
|
|
|
|
|
class Term(Base):
|
|
__table__ = schema.Terms
|
|
__tablename__ = __table__.name
|
|
__mapper_args__ = {"primary_key": [__table__.c.ID]}
|
|
|
|
def __init__(self, **kwargs):
|
|
super().__init__(**kwargs)
|
|
|
|
if not self.Description:
|
|
raise IntegrityError(
|
|
statement="Column Description cannot be null.",
|
|
orig="Terms.Description",
|
|
params=("NULL"))
|
|
|
|
if not self.URL:
|
|
raise IntegrityError(
|
|
statement="Column URL cannot be null.",
|
|
orig="Terms.URL",
|
|
params=("NULL"))
|