diff --git a/backend/apps/archive/models.py b/backend/apps/archive/models.py index fe85862..b71f1bd 100644 --- a/backend/apps/archive/models.py +++ b/backend/apps/archive/models.py @@ -1,5 +1,7 @@ from django.db import models +from apps.files.models import PostFileModel + class SourceSiteModel(models.Model): slug = models.CharField(max_length=64) @@ -47,3 +49,37 @@ class DescriptionModel(models.Model): def __str__(self): return str(self.hash) +class PostModel(models.Model): + post_id = models.CharField(max_length=128, db_index=True) + title = models.CharField(max_length=64) + description = models.ManyToManyField( + to=DescriptionModel, related_name="posts", through=PostDescription + ) + creator = models.ForeignKey( + to=CreatorModel, + on_delete=models.CASCADE, + null=True, + blank=True, + related_name="posts", + ) + source_site = models.ForeignKey( + to=SourceSiteModel, on_delete=models.CASCADE, related_name="posts" + ) + category = models.ManyToManyField(to=CategoryModel, related_name="posts") + + tags = models.ManyToManyField(to=TagModel, related_name="posts") + + mature = models.BooleanField(default=False) + + files = models.ManyToManyField(to=PostFileModel, related_name="posts") + + date_created = models.DateTimeField(auto_now_add=True, editable=True) + date_imported = models.DateTimeField(auto_now_add=True, editable=True) + date_last_import = models.DateTimeField(auto_now=True, editable=True) + + class Meta: + verbose_name = "Post" + verbose_name_plural = "Posts" + + def __str__(self): + return str(self.title)