~homeworkprod/byceps

ref: 4237b3ec9496efe95dcce82bea3207ab9de4d520 byceps/byceps/services/orga/models.py -rw-r--r-- 1007 bytes
4237b3ec — Jochen Kupperschmidt Move ticketing blueprint into `site` subpackage 1 year, 11 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
"""
byceps.services.orga.models
~~~~~~~~~~~~~~~~~~~~~~~~~~~

:Copyright: 2006-2020 Jochen Kupperschmidt
:License: Modified BSD, see LICENSE for details.
"""

from ...database import db
from ...typing import BrandID, UserID
from ...util.instances import ReprBuilder

from ..brand.models.brand import Brand
from ..user.models.user import User


class OrgaFlag(db.Model):
    """A user's organizer status for a single brand."""

    __tablename__ = 'orga_flags'

    brand_id = db.Column(db.UnicodeText, db.ForeignKey('brands.id'), primary_key=True)
    brand = db.relationship(Brand)
    user_id = db.Column(db.Uuid, db.ForeignKey('users.id'), primary_key=True)
    user = db.relationship(User)

    def __init__(self, brand_id: BrandID, user_id: UserID) -> None:
        self.brand_id = brand_id
        self.user_id = user_id

    def __repr__(self) -> str:
        return ReprBuilder(self) \
            .add('brand', self.brand_id) \
            .add('user', self.user.screen_name) \
            .build()