class Project(Model): id = fields.IntField(pk=True) name = fields.CharField(max_length=128) description = fields.TextField() link = fields.CharField(max_length=64) members = fields.ManyToManyField('models.Member', related_name='projects') leaders = fields.ManyToManyField('models.Leader', related_name='projects') organization = fields.ForeignKeyField('models.Organization', related_name='projects') tags: fields.ManyToManyRelation['Tag']
class Event(Model): id = fields.IntField(pk=True) name = fields.TextField() tournament = fields.ForeignKeyField('models.Tournament', related_name='events') participants = fields.ManyToManyField('models.Team', related_name='events', through='event_team') def __str__(self): return self.name
class Record(Model): id = fields.IntField(pk=True) name = fields.CharField(max_length=255) text = fields.TextField(blank=True, null=True) is_important = fields.BooleanField(default=False) create_date = fields.DatetimeField(auto_now_add=True) edit_date = fields.DatetimeField(auto_now=True) creator = fields.ForeignKeyField('models.User', related_name='records') class Meta: ordering = ['-edit_date']
class Article(AbstractTime): id = fields.IntField(pk=True) author = fields.ForeignKeyField('models.User') title = fields.CharField(max_length=250, index=True) body = fields.TextField() class Meta: table = 'blog_article' def __str__(self) -> str: return self.title
class UUIDFkRelatedNullModel(Model): id = fields.UUIDField(pk=True) name = fields.CharField(max_length=50, null=True) model: fields.ForeignKeyNullableRelation[ UUIDPkModel] = fields.ForeignKeyField("models.UUIDPkModel", related_name=False, null=True) parent: fields.OneToOneNullableRelation[ UUIDPkModel] = fields.OneToOneField("models.UUIDPkModel", related_name=False, null=True)
class Post(models.Model): id = fields.IntField(pk=True) title = fields.CharField(max_length=180) body = fields.TextField() picture = fields.CharField(max_length=256, null=True) author = fields.ForeignKeyField('models.User', related_name='user', on_delete='CASCADE') def __str__(self): return self.title
class Event(Model): id = fields.IntField(pk=True) name = fields.TextField() tournament = fields.ForeignKeyField("models.Tournament", related_name="events") participants = fields.ManyToManyField("models.Team", related_name="events", through="event_team") def __str__(self): return self.name
class Episode(Model): name = fields.CharEnumField(Shows) show = fields.ForeignKeyField('models.Show', related_name='episodes', on_delete=fields.RESTRICT) synopsis = fields.TextField() link = fields.CharField(max_length=255) air_date = fields.DatetimeField() def __str__(self): return self.name
class Event(Model): id = fields.IntField(pk=True) name = fields.TextField() created_at = fields.DatetimeField(auto_now_add=True) tournament: fields.ForeignKeyNullableRelation[ Tournament] = fields.ForeignKeyField("models.Tournament", related_name="events", null=True) class Meta: ordering = ["name"]
class Presets(Model): class Meta: unique_together = ('randomizer', 'preset_name', 'namespace') id = fields.IntField(pk=True) randomizer = fields.CharField(50) preset_name = fields.CharField(50) namespace = fields.ForeignKeyField('models.PresetNamespaces', related_name='presets') content = fields.TextField() modified = fields.DatetimeField(auto_now=True) generated_count = fields.IntField(default=0)
class Task(AbstractModel): name = fields.CharField(max_length=255, description="任务名称", unique=True) env = fields.ForeignKeyField('models.Env', related_name='task_env') cases = fields.ManyToManyField('models.Case', related_name='Tasks') is_timer = fields.BooleanField(default=False, description="定时任务开关") cron = fields.CharField(255, description="cron表达式", null=True, default=None) class PydanticMeta: max_recursion = 1
class DerivationOutputResult(models.Model): output = fields.ForeignKeyField( f"{app_name}.DerivationOutput", to_field="input_hash", on_delete=fields.CASCADE, db_constraint=False, index=True, ) # TODO: Turn into indexed CharField output_hash = trustix_fields.BinaryField(max_length=40) log = fields.ForeignKeyField( f"{app_name}.Log", on_delete=fields.CASCADE, ) # def __str__(self): # return f"{self.output_id}" # # return f"{self.log_id}({self.output.derivation_id, self.output.output})" class Meta(BaseMeta): unique_together = (("output", "log"), )
class User(models.Model): id = fields.IntField(pk=True) username = fields.CharField(max_length=256) organization = fields.ForeignKeyField('models.Organization', related_name='users') def __str__(self) -> str: return f"User {self.id}: {self.username}" def __repr__(self) -> str: return f"User {self.id}: {self.username}"
class AppVersion(BaseModel): app = fields.ForeignKeyField('models.App', related_name='app_versions') channel = fields.CharField(max_length=20, description='渠道') device_sys = fields.IntEnumField(DeviceSys, default=DeviceSys.android, description='操作系统') version_code = fields.CharField(max_length=20, description='版本号') describe = fields.CharField(max_length=200, description='描述') download_url = fields.CharField(max_length=200, description='下载链接') is_update = fields.BooleanField(default=False, description='是否更新') class Meta: ordering = ['-id'] indexes = (('app', 'device_sys', 'channel'),)
class SysAuthority(DateModelMixin, AbstractBaseModel): name = fields.CharField(max_length=150, description='角色名') parent: fields.ForeignKeyRelation['models.SysAuthority'] = fields.ForeignKeyField( 'models.SysAuthority', related_name='children', null=True ) children: fields.ReverseRelation['SysAuthority'] sys_menus: fields.ManyToManyRelation[SysMenu] = fields.ManyToManyField( 'models.SysMenu', through='sys_authority_menu' ) class Meta: table = "sys_authority"
class DiscordMember(Model): id = fields.IntField(pk=True) guild: DiscordGuild = fields.ForeignKeyField('models.DiscordGuild') user: DiscordUser = fields.ForeignKeyField('models.DiscordUser') initNum = fields.IntField(default=0) access_level = fields.IntEnumField(enum_type=AccessLevel, default=AccessLevel.DEFAULT) def get_access_level(self): override = self.user.access_level_override if override != AccessLevel.DEFAULT: return override else: return self.access_level class Meta: table = "members" def __repr__(self): return f"<Member user={self.user} guild={self.guild}>"
class Proposal(Model): id = fields.IntField(pk=True) dao = fields.ForeignKeyField('models.DAO', 'proposals') # upvotes = fields.IntField(default=0) # downvotes = fields.IntField(default=0) # start_date = fields.DatetimeField() # metadata = fields.JSONField() # proposer = fields.ForeignKeyField('models.Address', 'proposals') class Meta: table = 'proposals'
class Channel(TimestampModel): id: str = fields.CharField(max_length=50, pk=True) name: str = fields.CharField(max_length=255, index=True) monitor_file_name: str = fields.CharField(max_length=255, null=True) pin: str = fields.CharField(max_length=6, default='') from_number: str = fields.CharField(max_length=20, default='') request_number: str = fields.CharField(max_length=20, default='') bridged: fields.ManyToManyRelation['Channel'] = fields.ManyToManyField('models.Channel', related_name='bridged_set') call: fields.ForeignKeyNullableRelation['Call'] = fields.ForeignKeyField('models.Call', related_name='channels', null=True) bridged_set: fields.ManyToManyRelation['Channel'] records: fields.ForeignKeyNullableRelation['CallRecord']
class TelemetryEvent(models.Model): ''' This defines a Event for a matches Telemetry ''' id = fields.IntField(pk=True) event_type = fields.CharField(max_length=255) timestamp = fields.CharField(max_length=255, null=True) description = fields.CharField(max_length=1000) telemetry = fields.ForeignKeyField('api.Telemetry', on_delete=fields.CASCADE) player = fields.ForeignKeyField('api.Player', on_delete=fields.CASCADE, null=True) killer_x_cord = fields.FloatField(null=True) killer_y_cord = fields.FloatField(null=True) victim_x_cord = fields.FloatField(null=True) victim_y_cord = fields.FloatField(null=True) def __str__(self) -> str: return f"({self.event_type})[{self.timestamp}] : {self.description}"
class Task(Model): """Модель задачи урока.""" id = fields.IntField(pk=True) title = fields.CharField(max_length=32) condition = fields.TextField() example = fields.TextField() order_index = fields.IntField() lesson = fields.ForeignKeyField("models.Lesson", related_name="tasks") solutions: fields.ReverseRelation["models.TaskSolution"] # noqa: F821
class PostComment(models.Model): id = fields.IntField(pk=True) post: fields.ForeignKeyRelation[Post] = fields.ForeignKeyField( "models.Post", related_name="post_comments", on_delete=fields.CASCADE, ) user: fields.ForeignKeyRelation[User] = fields.ForeignKeyField( "models.User", related_name="post_comments", on_delete=fields.CASCADE, ) content = fields.TextField() created_at = fields.DatetimeField(auto_now_add=True) updated_at = fields.DatetimeField(auto_now=True) class PydanticMeta: exclude = ["created_at", "updated_at"] def __str__(self): return f"Comment of: {self.user.name}"
class PinnedMessage(Model): class Meta: table = 'pinned_message' unique_together = (('telegram_id', 'group_id'), ) id = fields.IntField(pk=True) group = fields.ForeignKeyField('models.Group', related_name='pinned_messages') text = fields.CharField(max_length=4096) author_id = fields.IntField() telegram_id = fields.IntField() sent = fields.DatetimeField()
class ReactionRoles(Model): emoji = fields.CharField(max_length=100) role_id = fields.IntField() template: fields.ForeignKeyRelation[Templates] = fields.ForeignKeyField( "models.Templates", related_name="reactionroles") class Meta: table = "ReactionRoles" def __str__(self): return self.name
class LevelingUserModel(Model): id = fields.UUIDField(pk=True) user = fields.ForeignKeyField("main.UserModel", related_name="LevelingUser") guild = fields.ForeignKeyField("main.GuildModel", related_name="LevelingUser") xp = fields.BigIntField(description="XP of the user in that guild!", default=0, null=True) level = fields.IntField(description="Level of the user!", default=0, null=True) image_banner = fields.TextField( description="BackGround image banner for the `rank` command", null=True) messages = fields.IntField(description="No. of messages sent by the user!", default=0) class Meta: table = "UserLeveling" table_description = "Represents the Leveling data for each user in a guild!"
class Team(Model): name = fields.CharField(max_length=50, pk=True, description="The TEAM name (and PK)") manager = fields.ForeignKeyField("models.Team", related_name="team_members", null=True) talks_to = fields.ManyToManyField("models.Team", related_name="gets_talked_to") class Meta: table_description = "The TEAMS!"
class HouseholdMember(Model): id = fields.IntField(pk=True) name = fields.CharField(100, unique=True) password_hash = fields.CharField(128) household = fields.ForeignKeyField('models.Household', related_name='members') @classmethod async def get_user(cls, name, **kwargs): return cls.get(name=name) def verify_password(self, password): return pwd_context.verify(password, self.password_hash)
class ReactionRole(Model): class Meta: table = 'reaction_role' id = fields.IntField(pk=True) guild_id = fields.BigIntField(null=False) reaction_group = fields.ForeignKeyField('models.ReactionGroup', related_name='reaction_roles') role_id = fields.BigIntField(null=True) name = fields.CharField(45, null=True) emoji = fields.CharField(200, null=True) protect_mentions = fields.SmallIntField(null=True)
class Post(Model): id = fields.IntField(pk=True) title = fields.CharField(max_length=100) body = fields.TextField() image = fields.CharField(max_length=250) author = fields.ForeignKeyField('diff_models.User', related_name='author', on_delete='CASCADE') created = fields.DatetimeField(auto_now=True) def __str__(self): return self.title
class Booking(models.Model): id = fields.IntField(pk=True) book_date = fields.DateField() book_status = fields.CharField(max_length=50) book_duration = fields.DatetimeField() class Meta: table = 'booking' facilities : fields.ForeignKeyRelation[Facility] = fields.ForeignKeyField("models.Facility", related_name="booking") user: fields.ManyToManyRelation[UserDetailModel] = fields.ManyToManyField("models.UserDetailModel", related_name="booking", through="user_booking", forward_key="user_id")
class SocialAccount(models.Model): """ Model social accounts """ account_id = fields.IntField() account_url = fields.CharField(max_length=500) account_login = fields.CharField(max_length=100) account_name = fields.CharField(max_length=100) provider = fields.CharField(max_length=100) # user = fields.ForeignKeyField('models.User', related_name='social_accounts') user: fields.ForeignKeyRelation[User] = fields.ForeignKeyField( "models.User", related_name="social_accounts")