class Projects(models.Model): """ Модель проекта """ id = fields.IntField(pk=True) #: Название проекта name = fields.CharField(max_length=50) #: Описание проекта description = fields.TextField() #: Статус проекта (0 - продолжается, 1 - закончен) status = fields.IntField() #: Дата начала проекта startdate = fields.DateField() #: Дата окончания проекта enddate = fields.DateField() #: Инвестиционный статус проекта (0 - не получены, 1 - получены) is_investment_status_accept = fields.IntField() #: Инвестор проекта (если есть) investor = fields.CharField(max_length=50) #: Нужен ли проекту инвестор (0 - не нужен, 1 - нужен) is_invest_need = fields.IntField() #: Сумма требуемых инвестиций (если требуются) investneedsum = fields.IntField() #: Id пользователя (telegram) telegram_id = fields.IntField()
class Rent(Model): id = fields.IntField(pk=True) start_date = fields.DateField() end_date = fields.DateField() client = fields.ForeignKeyField('models.User', related_name='client', on_delete=fields.CASCADE) ad_rent = fields.ForeignKeyField('models.Ad', related_name='ad_rent', on_delete=fields.CASCADE)
class user_items(Model): user_id = fields.BigIntField() gained_in = fields.BigIntField() id = fields.BigIntField(generated=True, pk=True) name = fields.CharField(max_length=2000) # rarity = fields.FloatField() float = fields.FloatField() tradable_after = fields.DateField() creatd_at = fields.DateField() nickname = fields.CharField(max_length=32, null=True, default=None) nicked = fields.BooleanField(default=False) rarity = fields.CharField(max_length=50, null=True) sellable = fields.BooleanField(default=True) tradable = fields.BooleanField(default=True)
class user_comments(Model): id = fields.BigIntField(generated=True, pk=True) author_id = fields.BigIntField(null=False) user_id = fields.BigIntField(null=False) comment = fields.CharField(max_length=1000, null=False) posted = fields.DateField()
class ScheduledVisit(models.Model): date = fields.DateField(auto_now_add=True) lesson: Lesson = fields.ForeignKeyField('lesson_schedule.Lesson', on_delete=fields.CASCADE) image: Optional[Path] = ImageField(upload_to='visit/', null=True) status = fields.CharEnumField(enums.VisitStatuses, default=enums.VisitStatuses.CREATED) error_message = fields.CharField(max_length=512, null=True) visit_start = fields.DatetimeField(null=True) visit_finish = fields.DatetimeField(null=True) # Relations owner: 'auth.User' = fields.ForeignKeyField( model_name='auth.User', related_name='visits', on_delete=fields.CASCADE, ) async def delete(self, using_db: Optional[BaseDBAsyncClient] = None) -> None: self._delete_img() return await super().delete(using_db) def set_image(self, image: Union[io.IOBase, Path, bytes]): if isinstance(image, bytes): buffer = io.BytesIO() buffer.name = f'{uuid.uuid4()}.png' buffer.write(image) image = buffer self._delete_img() self.image = image def _delete_img(self): if self.image: storage = ImageStorage.from_path(self.image) storage.delete(self.image.name)
class Todo(models.Model): id = fields.IntField(pk=True) todo = fields.CharField(max_length=250) due_date = fields.DateField() class PydanticMeta: pass
class User(Model, UserMixin): id = fields.UUIDField(pk=True) password = fields.CharField(80) given_name = fields.CharField(24) middle_name = fields.CharField(64, null=True) family_name = fields.CharField(64) nickname = fields.CharField(16, null=True) preferred_username = fields.CharField(16, null=True) profile = fields.CharField(128, null=True) picture = fields.CharField(256, null=True) website = fields.CharField(128, null=True) email = fields.CharField(64) email_verified = fields.BooleanField(default=False) gender = fields.CharEnumField(Genders, max_length=6, null=True) birthdate = fields.DateField(null=True) zoneinfo = fields.CharField(32, null=True) locale = fields.CharField(16, null=True) phone_number = fields.CharField(32, null=True) phone_number_verified = fields.BooleanField(default=False) address = fields.JSONField(null=True) created_at = fields.DatetimeField(auto_now_add=True) updated_at = fields.DatetimeField(auto_now=True) class Meta: table = "users" def get_user_id(self) -> str: return str(self.id)
class User(models.UUIDTimestampedModel, models.IndexedModel): """User model""" email = fields.CharField(max_length=244, null=True, unique=True) name = fields.CharField(max_length=50) surname = fields.CharField(max_length=50) birthday = fields.DateField() phone = fields.CharField(max_length=50) class Document(elastic.Document): id = elastic.fields.Keyword() uuid = elastic.fields.Keyword() email = elastic.fields.Keyword() name = elastic.fields.Text() class Index: name = 'user' @property def to_document(self) -> typing.Dict: """Return dict with the data that will be indexed""" return { 'id': self.id, 'uuid': self.uuid, 'email': self.email, 'name': self.name } class Meta: table = 'user'
class Tariff(Model): """Model for representing single tariff""" id = fields.IntField(pk=True) date = fields.DateField(default=None) cargo_type = fields.CharField(max_length=100, default=None) rate = fields.FloatField(default=None)
class cm_item(Model): user_id = fields.BigIntField() added_at = fields.DateField() id = fields.BigIntField(generated=True, pk=True) rarity = fields.CharField(max_length=50, null=True) float = fields.FloatField() name = fields.CharField(max_length=2000) price = fields.BigIntField()
class Registration(BaseModel): # user = fields.ForeignKeyField( # "models.User", related_name="users") department = fields.CharField(max_length=100, null=True) position = fields.CharField(max_length=100, null=True) portrait = fields.CharField(max_length=1000, null=True) profile = fields.TextField(null=True) birth = fields.DateField(null=True)
class DefaultModel(Model): int_default = fields.IntField(default=1) float_default = fields.FloatField(default=1.5) decimal_default = fields.DecimalField(max_digits=8, decimal_places=2, default=Decimal(1)) bool_default = fields.BooleanField(default=True) char_default = fields.CharField(max_length=20, default="tortoise") date_default = fields.DateField(default=datetime.date.fromisoformat("2020-05-20")) datetime_default = fields.DatetimeField(default=datetime.datetime(year=2020, month=5, day=20))
class StatisticsReport(Model): date = fields.DateField() rentals_started = fields.IntField() rentals_ended = fields.IntField() reservations_started = fields.IntField() reservations_cancelled = fields.IntField() distance_travelled = fields.FloatField() revenue = fields.FloatField()
class SavedWord(Model): id = fields.IntField(pk=True) words_group_name = fields.TextField() cdate = fields.DateField() from_language = fields.TextField() to_language = fields.TextField() from_word = fields.TextField() to_word = fields.TextField()
class Cargo(Model): """Model representing single cargo""" id = fields.IntField(pk=True) date = fields.DateField(default=None) cargo_type = fields.CharField(max_length=100, default=None) declared_cost = fields.FloatField(default=None) insurance_cost = fields.FloatField(default=None, null=True)
class Student(models.Model): id = fields.IntField(pk=True) name = fields.CharField(max_length=100) email = fields.CharField(max_length=120) password = fields.CharField(max_length=100) joined_date = fields.DateField(auto_now_Add=True) class Meta: pass
class Weather(Model): id = fields.IntField(pk=True) city = fields.CharField(max_length=255) date = fields.DateField(unique=True, default=datetime.now().date) temperature = fields.IntField() humidity = fields.IntField() def __str__(self): return ''.join(f'{key}:{val}, ' for key, val in self.__dict__.items())
class Works(models.Model): """ Модель работы """ id = fields.IntField(pk=True) #: Название организации name = fields.CharField(max_length=70) #: Должность position = fields.CharField(max_length=50) #: Статус работы (0 - актуально, 1 - закончил) status = fields.IntField() #: Дата начала работы startdate = fields.DateField() #: Дата окончания работы (если закончил) enddate = fields.DateField() #: Id пользователя (telegram) telegram_id = fields.IntField()
class users(Model): user_id = fields.BigIntField(unique=True, pk=True, null=False) balance = fields.BigIntField(default=5000) premium = fields.BooleanField(default=False) created_at = fields.DateField() bot_banned = fields.BooleanField(default=False) trade_banned = fields.BooleanField(default=False) shadow_trade_banned = fields.BooleanField(default=False) starter_cases = fields.BigIntField(default=10) firefight_cases = fields.BigIntField(null=True, default=None)
class Quizzes(Model): id = fields.IntField(pk=True) date = fields.DateField() difficulty = fields.CharField(255) quiz_type = fields.CharField(255) quiz_category = fields.IntField() questions = fields.ManyToManyField('models.Questions', related_name='quizzes') def __str__(self): return f"Quiz {self.id}: {self.date}, {self.difficulty}, {self.quiz_type}, {self.quiz_category}"
class Token(models.Model): """ Пользователь """ username = fields.CharField(max_length=128) token = fields.CharField(max_length=256) is_active = fields.BooleanField(default=True) date_create = fields.DateField(auto_now_add=True, null=True) class Meta: table = asf('token')
class ModelOperaciones(Model): id = fields.IntField(pk=True) descripcion = fields.CharField(max_length=200) fecha = fields.DateField() entrega = fields.DatetimeField(auto_now_add=True) observaciones = fields.CharField(max_length=300) personal = fields.ForeignKeyField('models.ModelPersonal') coche = fields.ForeignKeyField('models.ModelCoches') class Meta: table = 'operaciones'
class Event(models.Model): event_id = fields.UUIDField(pk=True) child: fields.ForeignKeyRelation[Child] = fields.ForeignKeyField( "my_child.Child", related_name="events", on_delete=fields.CASCADE) date = fields.DateField() has_come = fields.CharField(STR_MAX_LENGTH, null=True) has_gone = fields.CharField(STR_MAX_LENGTH, null=True) asleep = fields.CharField(STR_MAX_LENGTH, null=True) awoke = fields.CharField(STR_MAX_LENGTH, null=True) comment = fields.CharField(COMMENT_MAX_LENGTH, null=True) meals: fields.ReverseRelation["Meal"]
class Rates(models.Model): """ Model for storing data on insurance rate """ id = fields.IntField(pk=True) date = fields.DateField() cargo_type = fields.CharField(max_length=50) rate = fields.FloatField() class Meta: unique_together = ("date", "cargo_type")
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 BookSummary(Model): isbn = fields.CharField(max_length=80, unique=True) title = fields.TextField() volume = fields.CharField(max_length=80) series = fields.CharField(max_length=80) author = fields.TextField() publisher = fields.CharField(max_length=80) pubdate = fields.CharField(max_length=80) cover = fields.TextField() published_at = fields.DateField(null=True) def __str__(self): return self.title
class StatsDailyGuildMessages(IncrementableGuildValueModel): date = fields.DateField() class Meta: unique_together = (("date", "guild_id"), ) @classmethod async def get_for_now(cls, guild_id: int) -> "StatsDailyGuildMessages": return await cls.get_for_datetime(datetime.datetime.now(), guild_id) @classmethod async def get_for_datetime(cls, date: datetime.datetime, guild_id: int) -> "StatsDailyGuildMessages": return (await cls.get_or_create(date=date.date(), guild_id=guild_id))[0]
class Item(models.Model): """A model of items """ id = fields.IntField(pk=True) date = fields.DateField(auto_now=True) cargo_type = fields.TextField() rate = fields.FloatField() async def save(self, *args, **kwargs) -> None: await super().save(*args, **kwargs) class PydanticMeta: allow_cycles = False
class SomeModel(Model): id = fields.IntField(pk=True) string = fields.CharField(255, null=True) decimal = fields.DecimalField(20, 10, null=True) enum = fields.CharEnumField(SomeEnum, null=True) reversed_enum = ReversedCharEnumField(SomeReversedEnum, null=True) date = fields.DateField(null=True) datetime = fields.DatetimeField(null=True) timedelta = fields.TimeDeltaField(null=True) bool = fields.BooleanField(null=True) relation = fields.ForeignKeyField('models.SomeModel', 'id', null=True) class Meta: # pylint: disable=too-few-public-methods) table = 'test_models'
class Users(models.Model): """ Модель пользователя """ id = fields.IntField(pk=True) #: Id телеграм-аккаунта telegram_id = fields.IntField(unique=True) #: Имя first_name = fields.CharField(max_length=50, null=True) #: Фамилия last_name = fields.CharField(max_length=50, null=True) #: Роль role = fields.CharField(max_length=60) #: Город city = fields.CharField(max_length=20) #: Дата вступления startdate = fields.DateField(blank=False) #: Электронная почта email = fields.CharField(max_length=60) #: Ссылка на фейсбук fb = fields.CharField(max_length=60) #: Ссылка на вконтакте vk = fields.CharField(max_length=60) #: Номер телефона telnum = fields.CharField(max_length=60) #: День рождения birthday = fields.DateField(blank=False) #: Группа group = fields.CharField(max_length=60) #: Секрет-строка token = fields.CharField(max_length=20) #: Тип прав roots = fields.IntField() created_at = fields.DatetimeField(auto_now_add=True) modified_at = fields.DatetimeField(auto_now=True)