From 8eee273513745a7b0f2782d32aa062dacf9c0e3e Mon Sep 17 00:00:00 2001 From: Aroy-Art Date: Mon, 30 Dec 2024 23:10:10 +0100 Subject: [PATCH] Add sites Submissions model --- archivist/apps/sites/models.py | 36 ++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/archivist/apps/sites/models.py b/archivist/apps/sites/models.py index 638c4d0..59af499 100644 --- a/archivist/apps/sites/models.py +++ b/archivist/apps/sites/models.py @@ -57,3 +57,39 @@ class Users(models.Model): def get_absolute_url(self): return reverse('sites:artist_profile', args=[self.user_hash]) + + +class Submissions(models.Model): + + submission_hash = models.CharField(unique=True, max_length=64,) + date = models.DateTimeField(null=True, editable=True) + date_added = models.DateTimeField(auto_now_add=True, editable=True) + category = models.ForeignKey(Category, on_delete=models.CASCADE, null=True) + author = models.ForeignKey(Users, on_delete=models.CASCADE, null=True) + + mature = models.BooleanField(default=False) + + content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE, null=True) + object_id = models.PositiveBigIntegerField(null=True) + content_object = GenericForeignKey('content_type', 'object_id') + + + tags = models.ManyToManyField(Tags) + + custom_tags = models.ManyToManyField(CustomTags) + + description_length = models.PositiveIntegerField(default=0) + + class Meta: + verbose_name = _("Submission") + verbose_name_plural = _("Submissions") + + indexes = [ + models.Index(fields=['content_type', 'object_id']), + ] + + def __str__(self): + return self.submission_hash + + def get_absolute_url(self): + return reverse("sites:submission", args=[self.submission_hash])