@@ 18-44 (lines=27) @@ | ||
15 | from ...party.models.party import Party |
|
16 | ||
17 | ||
18 | class TourneyCategory(db.Model): |
|
19 | """One of potentially multiple tourney categories for a party.""" |
|
20 | ||
21 | __tablename__ = 'tourney_categories' |
|
22 | __table_args__ = ( |
|
23 | db.UniqueConstraint('party_id', 'title'), |
|
24 | ) |
|
25 | ||
26 | id = db.Column(db.Uuid, default=generate_uuid, primary_key=True) |
|
27 | party_id = db.Column(db.UnicodeText, db.ForeignKey('parties.id'), index=True, nullable=False) |
|
28 | party = db.relationship(Party, |
|
29 | backref=db.backref('tourney_categories', |
|
30 | order_by='TourneyCategory.position', |
|
31 | collection_class=ordering_list('position', count_from=1))) |
|
32 | position = db.Column(db.Integer, nullable=False) |
|
33 | title = db.Column(db.UnicodeText, nullable=False) |
|
34 | ||
35 | def __init__(self, party_id: PartyID, title: str) -> None: |
|
36 | self.party_id = party_id |
|
37 | self.title = title |
|
38 | ||
39 | def __repr__(self) -> str: |
|
40 | return ReprBuilder(self) \ |
|
41 | .add_with_lookup('id') \ |
|
42 | .add_with_lookup('party') \ |
|
43 | .add_with_lookup('title') \ |
|
44 | .build() |
|
45 |
@@ 37-67 (lines=31) @@ | ||
34 | .build() |
|
35 | ||
36 | ||
37 | class Collection(db.Model): |
|
38 | """A group of articles inside of catalog.""" |
|
39 | ||
40 | __tablename__ = 'shop_catalog_collections' |
|
41 | __table_args__ = ( |
|
42 | db.UniqueConstraint('catalog_id', 'title'), |
|
43 | ) |
|
44 | ||
45 | id = db.Column(db.Uuid, default=generate_uuid, primary_key=True) |
|
46 | catalog_id = db.Column(db.UnicodeText, db.ForeignKey('shop_catalogs.id'), index=True, nullable=False) |
|
47 | title = db.Column(db.UnicodeText, nullable=False) |
|
48 | position = db.Column(db.Integer, nullable=False) |
|
49 | ||
50 | catalog = db.relationship( |
|
51 | Catalog, |
|
52 | backref=db.backref( |
|
53 | 'collections', |
|
54 | order_by=position, |
|
55 | collection_class=ordering_list('position', count_from=1), |
|
56 | ), |
|
57 | ) |
|
58 | ||
59 | def __init__(self, catalog_id: CatalogID, title: str) -> None: |
|
60 | self.catalog_id = catalog_id |
|
61 | self.title = title |
|
62 | ||
63 | def __repr__(self) -> str: |
|
64 | return ReprBuilder(self) \ |
|
65 | .add_with_lookup('catalog_id') \ |
|
66 | .add_with_lookup('title') \ |
|
67 | .build() |
|
68 | ||
69 | ||
70 | class CatalogArticle(db.Model): |