aboutsummaryrefslogtreecommitdiff
path: root/models/user.py
blob: 4983a13dbf93e275cab52371d0fcefb450ca9a84 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from enum import IntEnum

from sqlalchemy.orm import Mapped, mapped_column

from models import BaseTable


class UserRole(IntEnum):
    REGULAR = 0
    ADMIN = 1


class User(BaseTable):
    __tablename__ = "user"

    id: Mapped[int] = mapped_column(primary_key=True, autoincrement=False)
    role: Mapped[UserRole] = mapped_column(default=UserRole.REGULAR)
    vpn_link: Mapped[str]

    def is_regular(self) -> bool:
        return self.role >= UserRole.REGULAR

    def is_admin(self) -> bool:
        return self.role == UserRole.ADMIN