Exemplo n.º 1
0
class Config(Model):
    label = fields.CharField(max_length=200)
    key = fields.CharField(max_length=20)
    value = fields.JSONField()
    status: Status = fields.IntEnumField(Status, default=Status.on)

    class Meta:
        table = "configs"
Exemplo n.º 2
0
class UserState(Model):
    id = fields.IntField(pk=True)
    uid = fields.IntField()
    branch = fields.CharField(32)
    context = fields.JSONField()

    class Meta:
        database = "user_state"
Exemplo n.º 3
0
class GameAttribute(Model):
    # These names should always be stored in uppercase.
    name = fields.CharField(null=False, max_length=100)
    mask = fields.BooleanField(null=False, default=False)
    userdata = fields.JSONField(null=True)

    class Meta:
        unique_together = (('name', 'mask'), )
class audio_cache(Model):
    audio_id = fields.IntField(pk=True, unique=True)
    content: dict = fields.JSONField()
    created = fields.DatetimeField(auto_now=True)
    timeout = timedelta(days=10)

    class Meta:
        table = "audio"
class live_cache(Model):
    room_id = fields.IntField(pk=True, unique=True)
    content: dict = fields.JSONField()
    created = fields.DatetimeField(auto_now=True)
    timeout = timedelta(minutes=5)

    class Meta:
        table = "live"
Exemplo n.º 6
0
class Config(Model):
    label = fields.CharField(max_length=200)
    key = fields.CharField(max_length=20)
    value = fields.JSONField()
    status: Status = fields.IntEnumField(Status, default=Status.on)

    def __str__(self):
        return f"{self.pk}#{self.label}"
Exemplo n.º 7
0
class User(Model):
    id = fields.IntField(pk=True)
    username = fields.CharField(50, unique=True)
    password_hash = fields.CharField(128)
    board_data = fields.JSONField(
        default='{"tasks": {}, "columns": {}, "columnOrder": []}')

    def verify_password(self, password):
        return bcrypt.verify(password, self.password_hash)
Exemplo n.º 8
0
class User(MyModel):
    class Meta:
        table = 'users'
        table_description = 'Users :)'

    id = fields.IntField(pk=True)
    name = fields.TextField()
    username = fields.TextField()
    email = fields.TextField()
    address = fields.JSONField()
    phone = fields.TextField()
    website = fields.TextField()
    company = fields.JSONField()

    key_fields = ['id']
    data_fields = [
        'name', 'username', 'email', 'address', 'phone', 'website', 'company'
    ]
class reply_cache(Model):
    oid = fields.BigIntField(pk=True, unique=True)
    reply_type = fields.IntField()
    content: dict = fields.JSONField()
    created = fields.DatetimeField(auto_now=True)
    timeout = timedelta(minutes=20)

    class Meta:
        table = "reply"
Exemplo n.º 10
0
class video_cache(Model):
    aid = fields.BigIntField(pk=True, unique=True)
    bvid = fields.CharField(max_length=12, unique=True)
    content: dict = fields.JSONField()
    created = fields.DatetimeField(auto_now=True)
    timeout = timedelta(days=10)

    class Meta:
        table = "video"
Exemplo n.º 11
0
class bangumi_cache(Model):
    epid = fields.IntField(pk=True, unique=True)
    ssid = fields.IntField()
    content: dict = fields.JSONField()
    created = fields.DatetimeField(auto_now=True)
    timeout = timedelta(days=10)

    class Meta:
        table = "bangumi"
Exemplo n.º 12
0
class dynamic_cache(Model):
    dynamic_id = fields.BigIntField(pk=True, unique=True)
    rid = fields.BigIntField(unique=True)
    content: dict = fields.JSONField()
    created = fields.DatetimeField(auto_now=True)
    timeout = timedelta(days=10)

    class Meta:
        table = "dynamic"
Exemplo n.º 13
0
class FilterModel(models.Model):
    """
    The User model
    """
    json_data_params = fields.JSONField()
    date_create = fields.DatetimeField(auto_now_add=True)
    url = fields.ForeignKeyField('models.UsersAnonModel',
                                 related_name="urlclick",
                                 null=True)
Exemplo n.º 14
0
class Configs(BaseModel, DatetimeMixin, StatusMixin):
    key = fields.CharField(64, unique=True, index=True, null=False)
    version = fields.IntField(index=True, null=False)
    config = fields.JSONField(encoder=json.dumps,
                              decoder=json.loads,
                              null=False)

    class Meta:
        table = "configs"
Exemplo n.º 15
0
class Services(models.Model):
    id: int = fields.IntField(pk=True)
    name: str = fields.CharField(max_length=100, unique=True, index=True)
    url: str = fields.CharField(max_length=500, unique=True)
    method: str = fields.CharField(max_length=25)
    header: dict = fields.JSONField(null=True)
    static_data: dict = fields.JSONField(null=True)
    dynamic_data: dict = fields.JSONField(null=True)

    def get_json_schema(self) -> Dict[str, Optional[str]]:
        return {
            'name': self.name,
            "url": self.url,
            "method": self.method,
            "header": self.header,
            "static_data": self.static_data,
            "dynamic_data": self.dynamic_data
        }
Exemplo n.º 16
0
class PagePostAttachment(PagePostAttributesAbstractModel):
    type = fields.CharField(max_length=64, null=False)
    title = fields.CharField(max_length=256, null=True)
    url = fields.TextField(null=True)
    description = fields.TextField(null=True)
    target = fields.JSONField(null=True)

    class Meta:
        table = "pages_post_attachment"
Exemplo n.º 17
0
class AbstractAdminLog(Model):
    admin_log_id = fields.IntField(pk=True)
    admin = fields.ForeignKeyField("models.User")
    action = fields.CharField(max_length=20)
    model = fields.CharField(max_length=50)
    content = fields.JSONField()

    class Meta:
        abstract = True
Exemplo n.º 18
0
class Message(Model):
    id = fields.IntField(pk=True)
    uid = fields.CharField(max_length=255)

    mailboxes = fields.ManyToManyField("models.Mailbox",
                                       related_name="messages")

    status = fields.CharField(max_length=255)
    timestamp = fields.DatetimeField()
    # unread = fields.BooleanField()
    incoming = fields.BooleanField()
    # body = fields.TextField()

    attachments = fields.JSONField(default=[])
    data = fields.JSONField(encoder=MyJSONEncoder().encode,
                            decoder=MyJSONDecoder().decode)

    def update_from_dict(self, data):
        data = dict(data)
        self.uid = data.pop("uid")
        self.status = data.pop("status")
        # self.unread = data.pop("unread")
        self.timestamp = data.pop("date")
        self.incoming = data.pop("incoming")
        self.attachments = data.pop("attachments")
        self.data = data

    def as_dict(self):
        data = dict(self.data)
        data["uid"] = self.uid
        data["status"] = self.status
        # data["unread"] = self.unread
        data["date"] = self.timestamp
        data["incoming"] = self.incoming
        data["attachments"] = self.attachments

        return data

    def as_mini_dict(self):
        data = self.as_dict()
        del data["body"]

        return data
Exemplo n.º 19
0
class Session(Model):
    """ Users session """

    id = fields.IntField(pk=True)
    key = fields.CharField(max_length=255)

    content = fields.JSONField(default=list)

    def as_dict(self):
        return self.content
Exemplo n.º 20
0
class QueryString(Model):
    """This is the database model capturing the user submitted queries."""
    id = fields.IntField(pk=True)
    query = fields.CharField(max_length=1024)
    language = fields.CharEnumField(max_length=0, enum_type=Language)
    results = fields.JSONField(null=True)
    created = fields.DatetimeField(auto_now_add=True)

    def __str__(self) -> str:
        return self.query
class FicheActionCategorie(models.Model):
    id = fields.IntField(pk=True)
    epci_id = fields.CharField(max_length=36)
    uid = fields.CharField(max_length=36)
    parent_uid = fields.CharField(max_length=36)
    nom = fields.CharField(max_length=300)
    fiche_actions_uids = fields.JSONField()
    created_at = fields.DatetimeField(auto_now_add=True)
    modified_at = fields.DatetimeField(auto_now=True)
    latest = fields.BooleanField()
    deleted = fields.BooleanField()
Exemplo n.º 22
0
class DiscordMember(Model):
    id = fields.IntField(pk=True)
    guild = fields.ForeignKeyField('models.DiscordGuild')
    user = fields.ForeignKeyField('models.DiscordUser')
    permissions = fields.JSONField(default={})

    class Meta:
        table = "members"

    def __repr__(self):
        return f"<Member user={self.user} guild={self.guild}>"
Exemplo n.º 23
0
class Answer(Model):
    id = fields.IntField(pk=True)
    name = fields.CharField(64)
    grade_name = fields.CharField(64)
    cafe_name = fields.JSONField()
    feedback = fields.TextField()

    created_at = fields.DatetimeField(auto_now_add=True)

    def __str__(self):
        return f'Answer<id:{self.id}, name:{self.name}, grade_name:{self.grade_name}, cafe_name:{self.cafe_name}>'
Exemplo n.º 24
0
class DiscordUser(Model):
    discord_id = fields.BigIntField(pk=True)
    first_seen = fields.DatetimeField(auto_now_add=True)

    support_tickets: fields.ReverseRelation[SupportTicket]
    closed_tickets: fields.ReverseRelation[SupportTicket]
    # inventory: fields.OneToOneRelation[UserInventory]

    members: fields.ReverseRelation["DiscordMember"]

    votes: fields.ReverseRelation["Vote"]
    tags: fields.ReverseRelation["Tag"]
    tags_aliases: fields.ReverseRelation["TagAlias"]

    name = fields.TextField()
    discriminator = fields.CharField(4)

    trophys = fields.JSONField(default=dict)

    ping_friendly = fields.BooleanField(default=True)

    language = fields.CharField(6, default="en")
    first_use = fields.BooleanField(default=True)

    access_level_override = fields.IntEnumField(enum_type=AccessLevel,
                                                default=AccessLevel.DEFAULT)

    boss_kills = fields.IntField(default=0)

    async def get_or_create_support_ticket(self) -> SupportTicket:
        support_ticket: typing.Optional[
            SupportTicket] = await SupportTicket.filter(user=self,
                                                        closed=False).first()

        if not support_ticket:
            support_ticket = SupportTicket(user=self)

        return support_ticket

    async def support_ticket_count(self, **filter_kwargs) -> int:
        return await SupportTicket.filter(user=self, **filter_kwargs).count()

    class Meta:
        table = "users"

    def get_access_level(self):
        return self.access_level_override

    def __str__(self):
        return self.name

    def __repr__(self):
        return f"<User name={self.name}#{self.discriminator}>"
Exemplo n.º 25
0
class LogstfData(Model):
    game_id = fields.IntField(pk=True, generated=False)
    uploader_id = fields.IntField()
    game_map = fields.CharField(max_length=25)
    game_date = fields.DatetimeField()
    game_title = fields.CharField(max_length=255)
    game_data = fields.JSONField()

    class Meta:
        table = "logstf"
        table_description = "Stores raw logstf data for all matches"
        unique_together = ('game_id', 'uploader_id')
Exemplo n.º 26
0
class LeaguePlayoffs(Model):
    class Meta:
        table = 'league_playoffs'

    episode_id = fields.IntField(pk=True, generated=False)
    playoff_round = fields.CharField(45, null=True)
    game_number = fields.IntField(null=True)
    type = fields.CharField(45, null=True)
    preset = fields.CharField(45, null=True)
    settings = fields.JSONField(null=True)
    submitted = fields.SmallIntField(null=True)
    created = fields.DatetimeField(auto_now_add=True)
    modified = fields.DatetimeField(auto_now=True)
Exemplo n.º 27
0
class TournamentGames(Model):
    class Meta:
        table = 'tournament_games'

    episode_id = fields.IntField(pk=True, generated=False)
    event = fields.CharField(45, null=True)
    game_number = fields.IntField(null=True)
    settings = fields.JSONField(null=True)
    preset = fields.CharField(100, null=True)
    notes = fields.TextField(null=True)
    submitted = fields.SmallIntField(null=True)
    created = fields.DatetimeField(auto_now_add=True)
    updated = fields.DatetimeField(auto_now=True)
Exemplo n.º 28
0
class User(Model, TimestampMixin):
    class Meta:
        table = 'user'

    id: UUID = fields.UUIDField(pk=True)
    email = fields.CharField(max_length=255)
    account = fields.CharField(max_length=64, null=True)
    hashed_password = fields.CharField(max_length=64, null=True)
    third_party_user_id = fields.TextField(null=True)
    type = fields.IntEnumField(UserType)
    status = fields.IntEnumField(UserStatus, default=UserStatus.NORMAL)
    is_email_verified = fields.BooleanField(default=False)
    extra = fields.JSONField(default={})
Exemplo n.º 29
0
class TelemetryRoster(models.Model):
    ''' 
		This defines a Roster from the Telemetry
	'''

    id = fields.IntField(pk=True)
    json = fields.JSONField()
    telemetry = fields.ForeignKeyField('api.Telemetry',
                                       on_delete=fields.CASCADE,
                                       null=True)

    def __str__(self) -> str:
        return self.json
Exemplo n.º 30
0
class Player(models.Model):
    ''' 
		This defines a Player from the PUBG API
	'''

    id = fields.IntField(pk=True)
    api_id = fields.CharField(max_length=255)
    platform_url = fields.CharField(max_length=255, null=True)
    api_url = fields.CharField(max_length=255)
    alternative_names = fields.JSONField()

    def __str__(self) -> str:
        return self.api_id