class Subscription(models.Model): class SubscriptionTypeChoices(models.IntegerChoices): BASE = 1, 'Базовая подписка' ADVANCED = 2, 'Продвинутая подписка' PRO = 3, 'PRO подписка' user = models.ForeignKey(User, verbose_name='Подписавшийся', related_name='user_subscription', on_delete=models.CASCADE) subscription_plan = models.IntegerField( 'План подписки', choices=SubscriptionTypeChoices.choices, default=1) start_date = UnixTimeStampField(verbose_name='Дата начала') end_date = UnixTimeStampField(verbose_name='Дата конца', ) length = models.IntegerField('Длительность в днях') paid_amount = models.IntegerField('Сумма оплаты') paid = models.BooleanField('Оплачено', default=False) finished = models.BooleanField('Завершена', default=False) def get_date_range(self): return str(self.start_date) + ' -- ' + str(self.end_date) get_date_range.short_description = 'Начало конец подписки' class Meta: verbose_name = 'Подписка' verbose_name_plural = 'Подписки' def __str__(self): return f"{self.pk}-{self.user}"
class Calendar(models.Model): # constants MAX_LABEL_LENGTH = 64 # properties user = models.ForeignKey(User, on_delete=models.CASCADE, related_name="calendars") label = models.CharField( max_length=MAX_LABEL_LENGTH, validators=[validate_slug, MaxLengthValidator(MAX_LABEL_LENGTH)]) detail = models.TextField(blank=True, null=True) triage = models.SmallIntegerField() do_remind = models.BooleanField(default=False) remind_minutes = models.SmallIntegerField() from_time = UnixTimeStampField(use_numeric=True) to_time = UnixTimeStampField(use_numeric=True) updated_time = UnixTimeStampField(auto_now_add=True, use_numeric=True) created_time = UnixTimeStampField(auto_now=True, use_numeric=True) class Meta: verbose_name = 'user calendar table' verbose_name_plural = verbose_name ordering = ['from_time']
class Partner(models.Model): id = models.IntegerField(default=0, primary_key=True) user = models.ForeignKey(User, default=1, on_delete=models.CASCADE) name = models.CharField(max_length=160, blank=False) city = models.CharField(max_length=100, blank=False) address = models.CharField(max_length=200, blank=False) company_name = models.CharField(max_length=160, blank=False) cars = ArrayField( models.IntegerField(), blank=True, default=list ) created_at = UnixTimeStampField( auto_now_add=True, use_numeric=True, round_to=3, blank=False ) modify_at = UnixTimeStampField( auto_now=True, use_numeric=True, round_to=3, blank=False ) deleted_at = UnixTimeStampField( default=0, use_numeric=True, round_to=3 ) def __str__(self): return self.name
class GdzBook(BaseModel, TimestampModel, ViewCounterModel): author = models.CharField(max_length=255) gdz_clas = models.ForeignKey('GdzClas', models.DO_NOTHING, blank=True, null=True, related_name='gdz_clas_books') gdz_subject = models.ForeignKey('GdzSubject', models.DO_NOTHING, blank=True, null=True, related_name='gdz_subject_books') img = models.CharField(max_length=255, blank=True, null=True) description = models.TextField(blank=True, null=True) year = models.CharField(max_length=255, blank=True, null=True) properties = models.CharField(max_length=255, blank=True, null=True) pagination = models.CharField(max_length=255, blank=True, null=True) public_time = UnixTimeStampField(auto_now_add=True, use_numeric=True) lang = models.CharField(max_length=255, blank=True, null=True) public = models.BooleanField() edition = models.CharField(max_length=255, blank=True, null=True) info = models.CharField(max_length=255, blank=True, null=True) vk_img = models.IntegerField(blank=True, null=True) vk_public_time = UnixTimeStampField(blank=True, null=True, use_numeric=True) is_promote = models.BooleanField() class Meta: db_table = 'gdz_book' objects = models.Manager() published = PublishedManager() def get_absolute_url(self): return reverse('gdz:book', args=[self.gdz_clas.slug, self.gdz_subject.slug, self.slug]) def save(self, *args, **kwargs): self.uri = reverse('gdz:book', args={self.gdz_clas.slug, self.gdz_subject.slug, self.slug}) super(GdzBook, self).save(*args, **kwargs)
class Partner(models.Model): id = models.AutoField(primary_key=True) name = models.CharField(max_length=160) city = models.CharField(max_length=180) address = models.CharField(max_length=200) company_name = models.CharField(max_length=200) created_at = UnixTimeStampField(auto_now_add=True, use_numeric=True) modified_at = UnixTimeStampField(auto_now=True, use_numeric=True) deleted_at = UnixTimeStampField(null=True, blank=True, use_numeric=True)
class RejectedUsers(models.Model): user = models.ForeignKey(SpooferUser) asn = models.IntegerField() ip_network = models.GenericIPAddressField() date = UnixTimeStampField(auto_now_add=True) user = models.ForeignKey(SpooferUser) comments = models.CharField(max_length=200, default='') date = UnixTimeStampField(auto_now_add=True) platform = models.CharField(max_length=10, default='') deny_on_sub = models.BooleanField(default=False)
class TimestampModel(models.Model): class Meta: abstract = True create_time = UnixTimeStampField(auto_now_add=True, use_numeric=True, default=0.0) update_time = UnixTimeStampField(auto_now=True, use_numeric=True, default=0.0)
class Place(models.Model): title = models.CharField(max_length=255) slug = models.CharField(unique=True, max_length=255) created_at = UnixTimeStampField(auto_now_add=True) updated_at = UnixTimeStampField(auto_now=True) refresh = models.IntegerField(blank=True, null=True) type = models.CharField(max_length=255, blank=True, null=True) is_active = models.BooleanField(default=False) entity = models.CharField(max_length=255, blank=True, null=True) banner = models.ManyToManyField(Banner, through='PlaceBanner', verbose_name='books') class Meta: db_table = 'place'
class Partner(models.Model): id = models.IntegerField(blank=False, default=0, primary_key=True) name = models.CharField(blank=False, max_length=160) city = models.CharField(blank=False, max_length=200) address = models.CharField(blank=False, max_length=200) company_name = models.CharField(blank=False, max_length=200) assigned_autos = ArrayField(models.CharField(max_length=10, blank=True), default=list) created_at = UnixTimeStampField(auto_now_add=True) modify_at = UnixTimeStampField(auto_now=True) deleted_at = UnixTimeStampField(auto_now=True) autos = models.ManyToManyField('Auto', through='AutoPartnerRelation') def __str__(self): return str(self.id)
class Car(models.Model): id = models.AutoField(primary_key=True) average_fuel = models.FloatField() delegation_starting = UnixTimeStampField() delegation_ending = UnixTimeStampField() driver = models.CharField(max_length=160) owner = models.CharField(max_length=160) type = models.CharField(max_length=20) partners = models.ManyToManyField(Partner, blank=True, related_name='cars_set', editable=False) created_at = UnixTimeStampField(auto_now_add=True, use_numeric=True) modified_at = UnixTimeStampField(auto_now=True, use_numeric=True) deleted_at = UnixTimeStampField(null=True, blank=True, use_numeric=True)
class CommentModel(MPTTModel): comment_id = models.AutoField(primary_key=True) comment_text = models.TextField(null=True) content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE, default=None, blank=True) commented_object_id = models.PositiveIntegerField() commented_object = GenericForeignKey('content_type', 'commented_object_id') comment_date = UnixTimeStampField(auto_now_add=True) comment_image = models.URLField(blank=True) comment_vote = models.IntegerField(default=0) comment_owner = models.ForeignKey(UserModel, on_delete=models.CASCADE) parent = TreeForeignKey('self', null=True, blank=True, related_name='children') def save(self): if self.parent is not None: self.commented_object = self.parent super().save(self) def __str__(self): return self.comment_text class MPTTMeta: level_attr = 'mptt_level' order_insertion_by = ['comment_text']
class Event(models.Model): """Event's Fields.""" uuid = models.UUIDField( primary_key=True, editable=False, unique=True, ) name = models.CharField(max_length=50) reporter = models.ForeignKey( 'Reporter', related_name='events', on_delete=models.PROTECT, ) description = models.TextField() type = models.ForeignKey( 'EventType', related_name='events', on_delete=models.PROTECT, ) location = GeopositionField() datetime = UnixTimeStampField(use_numeric=True) class Meta: verbose_name = "Event" verbose_name_plural = "Events" def __str__(self): return self.name
class User(AbstractUser): # constants MIN_PASSWORD_LENGTH = 8 MAX_PASSWORD_LENGTH = 512 PASSWORD_SALT= 'alan-data-science-web-app' # properties password = models.CharField( max_length = MAX_PASSWORD_LENGTH, validators = [ MinLengthValidator(MIN_PASSWORD_LENGTH), MaxLengthValidator(MAX_PASSWORD_LENGTH) ] ) updated_time = UnixTimeStampField(auto_now_add = True) objects = ModelManager() class Meta: verbose_name = 'user information table' verbose_name_plural = verbose_name def __str__(self) -> str: return self.username def set_password(self, password) -> None: self.password = make_password(password, salt = self.PASSWORD_SALT) def do_check_password(self, password) -> bool: return check_password(password, self.password)
class RawEvent(models.Model): id = models.AutoField(primary_key=True, unique=True) session = models.ForeignKey(Session, on_delete=models.CASCADE) created_at = UnixTimeStampField(default=0.0) class Meta: abstract = True
class ProANoBonus(models.Model): pro_id = models.AutoField(primary_key=True) user = models.ForeignKey(SpooferUser) worker_id = models.CharField(max_length=50, default='') date = UnixTimeStampField(auto_now_add=True) class Meta: unique_together = ('pro_id', 'user')
class Post(models.Model): created_at = UnixTimeStampField(auto_now_add=True, use_numeric=True) title = models.CharField(max_length=100) content = models.TextField() class Meta: ordering = ["-created_at"] objects = PostManager()
class IPAddresses(models.Model): ipv4_dns = models.GenericIPAddressField() ipv6_dns = models.GenericIPAddressField(protocol='IPv6') ip_ds = models.GenericIPAddressField(protocol='both') # change this ip_ds_lp = models.GenericIPAddressField(protocol='both') ipv4_nodns = models.GenericIPAddressField() ipv6_nodns = models.GenericIPAddressField(protocol='IPv6') date = UnixTimeStampField(auto_now_add=True)
class Comments(models.Model): user = models.ForeignKey(SpooferUser) comments = models.CharField(max_length=200, default='') date = UnixTimeStampField(auto_now_add=True) platform = models.CharField(max_length=10, default='') worker_id = models.IntegerField(default=0) class Meta: unique_together = ("user", "comments", "date")
class Candidate(models.Model): tsync_id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False, max_length=55) name = models.CharField(max_length=256, blank=False) email = models.EmailField(max_length=256, blank=False) phone_regex = RegexValidator( regex=r'^\+?1?\d{9,14}$', message="Phone number must be entered in the format: '+999999999'") phone = models.CharField(validators=[phone_regex], max_length=14, blank=False) full_address = models.CharField(max_length=512, null=True, blank=True) name_of_university = models.CharField(max_length=256, blank=False) graduation_year = models.PositiveIntegerField( validators=[MinValueValidator(2015), MaxValueValidator(2020)], blank=False) cgpa = models.FloatField( validators=[MinValueValidator(2.0), MaxValueValidator(4.0)], blank=True) experience_in_months = models.PositiveIntegerField( validators=[MinValueValidator(0), MaxValueValidator(100)], blank=True) current_work_place_name = models.CharField(max_length=256, blank=True) applying_in = models.CharField(max_length=200) expected_salary = models.PositiveIntegerField( validators=[MinValueValidator(15000), MaxValueValidator(60000)], blank=False) field_buzz_reference = models.CharField(max_length=256, blank=True) github_project_url = models.URLField(max_length=512, blank=False) my_file = models.FileField(upload_to='files/', null=True, blank=False, validators=[FileExtensionValidator(['pdf'])]) cv_file_tsync_id = models.UUIDField(unique=True, default=uuid.uuid4, editable=False, max_length=55) on_spot_update_time = UnixTimeStampField(auto_now=True) on_spot_creation_time = UnixTimeStampField(auto_now_add=True)
class Location(models.Model): route = models.ForeignKey(Route, on_delete=models.CASCADE) timestamp = UnixTimeStampField(default=0.0) longitude = models.FloatField(default=0) latitude = models.FloatField(default=0) accuracy = models.FloatField(default=0) speed = models.FloatField(default=0) def __str__(self): return str(self.timestamp)
class InfoBotHistory(models.Model): """ Log replies from the Telegram """ update_id = models.IntegerField(null=True) group_chat_id = models.IntegerField(null=True) user_chat_id = models.IntegerField(null=True) chat_title = models.CharField(max_length=256, default="") username = models.CharField(max_length=32, default="") bot_command_text = models.CharField(max_length=64, default="") language_code = models.CharField(max_length=8, default="") datetime = UnixTimeStampField(null=False)
class Volume(models.Model): source = models.SmallIntegerField(choices=SOURCE_CHOICES, null=False) transaction_currency = models.CharField(max_length=6, null=False, blank=False) counter_currency = models.SmallIntegerField( choices=COUNTER_CURRENCY_CHOICES, null=False, default=BTC) volume = models.FloatField(null=False) timestamp = UnixTimeStampField(null=False)
class Car(models.Model): id = models.IntegerField(default=0, primary_key=True) user = models.ForeignKey(User, default=1, on_delete=models.CASCADE) average_fuel = models.DecimalField( max_digits=6, decimal_places=2, default=0 ) delegation_starting = UnixTimeStampField(use_numeric=True, default=0) delegation_ending = UnixTimeStampField(use_numeric=True, default=0) driver = models.CharField(max_length=160) owner = models.CharField(max_length=160) TYPE_CHOICES = ( ('pr', 'private'), ('co', 'company'), ) type = models.CharField(max_length=2, choices=TYPE_CHOICES, default='co') partners = ArrayField( models.IntegerField(), blank=True, default=list ) created_at = UnixTimeStampField( auto_now_add=True, use_numeric=True, round_to=3, blank=False ) modify_at = UnixTimeStampField( auto_now=True, use_numeric=True, round_to=3, blank=False ) deleted_at = UnixTimeStampField( default=0, use_numeric=True, round_to=3 ) def __str__(self): return str(self.id)
class SemanticEvent(models.Model): id = models.AutoField(primary_key=True, unique=True) session = models.ForeignKey(Session, on_delete=models.CASCADE, related_name='semantic_events') event_type = models.ForeignKey(EventType, on_delete=models.CASCADE) element_type = models.ForeignKey(ElementType, on_delete=models.CASCADE) created_at = UnixTimeStampField(default=0.0) class Meta: db_table = 'semantic_event'
class Auto(models.Model): id = models.IntegerField(default=0, primary_key=True) average_fuel = models.IntegerField(default=0) delegation_starting = UnixTimeStampField(auto_now_add=True) delegation_ending = UnixTimeStampField(auto_now_add=True) driver = models.CharField(max_length=100) owner = models.CharField(max_length=100) COMPANY = 'Company' PRIVATE = 'Private' type = models.CharField(choices=[(COMPANY, 'Company'), (PRIVATE, 'Private')], max_length=200) assigned_partners = ArrayField(models.CharField(max_length=10, blank=True), default=list) created_at = UnixTimeStampField(auto_now_add=True) modify_at = UnixTimeStampField(auto_now=True) deleted_at = UnixTimeStampField(auto_now=True) partners = models.ManyToManyField('Partner', through='AutoPartnerRelation') def __str__(self): return str(self.id)
class RecipeQuery(models.Model): class Meta: verbose_name = 'レシピ検索履歴' verbose_name_plural = 'レシピ検索履歴' image = models.ImageField(verbose_name='画像', upload_to='from_microwaves/') oven = models.ForeignKey(Oven, verbose_name="機種", on_delete=models.CASCADE) received_at = UnixTimeStampField( verbose_name=_('問い合わせ日時'), use_numeric=True, auto_now_add=True, )
class Blog(models.Model): # user = models.ForeignKey('auth.User', related_name='blog', on_delete=models.CASCADE) name = models.TextField(blank=False, null=False) content = models.TextField(blank=False, null=False) modified_at = models.DateTimeField(auto_now=True) createdAt = UnixTimeStampField(auto_now_add=True) class Meta: ordering = ['createdAt'] def save(self, *args, **kwargs): super(Blog, self).save(*args, **kwargs)
class Post(models.Model): tsync_id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=True) name = models.TextField() email = models.EmailField(max_length=256) phone = models.TextField() full_address = models.TextField() name_of_university = models.TextField() graduation_year = models.IntegerField() cgpa = models.FloatField() experience_in_months = models.IntegerField() current_work_place_name = models.TextField() applying_in = models.TextField() expected_salary = models.IntegerField() field_buzz_reference = models.TextField() github_project_url = models.URLField(max_length=512) cv_file = models.URLField(max_length=512) on_spot_update_time = UnixTimeStampField(auto_now=True) on_spot_creation_time = UnixTimeStampField(auto_now_add=True) def __str__(self): return self.tsync_id, self.name, self.email, self.phone, self.full_address, self.name_of_university, self.graduation_year, self.cgpa, self.experience_in_months, self.current_work_place_name, self.applying_in, self.expected_salary, self.field_buzz_reference, self.github_project_url, self.cv_file, self.on_spot_update_time, self.on_spot_creation_time
class MetricList(BaseModel): timestamp = UnixTimeStampField(default=now) userId = models.CharField(null=True,max_length=50) instanceId = models.CharField(null=True,max_length=50) MetricName = models.CharField(null=True, max_length=50) Maximum = models.CharField(null=True,max_length=10) Minimum = models.CharField(null=True, max_length=10) Average = models.CharField(null=True, max_length=10) create_time = models.DateTimeField(default=now, blank=True, verbose_name="创建时间",db_index=True) is_delete = None class Meta: unique_together = ['timestamp','instanceId','MetricName']
class AbstractIndicator(models.Model): source = models.SmallIntegerField(choices=SOURCE_CHOICES, null=False) counter_currency = models.SmallIntegerField(choices=COUNTER_CURRENCY_CHOICES, null=False, default=BTC) transaction_currency = models.CharField(max_length=6, null=False, blank=False) timestamp = UnixTimeStampField(null=False) resample_period = models.PositiveSmallIntegerField(null=False, default=PERIODS_LIST[0]) # minutes (eg. 15) # MODEL PROPERTIES # MODEL FUNCTIONS class Meta: abstract = True