Some checks failed
Build and Push to Docker Hub / build-test-push (push) Failing after 1m55s
48 lines
1.1 KiB
Python
48 lines
1.1 KiB
Python
from django.db import models
|
|
from polymorphic import models as polymorphic
|
|
from django.utils.translation import gettext as _
|
|
|
|
|
|
class Tags(models.Model):
|
|
name = models.CharField(max_length=255)
|
|
|
|
def __str__(self):
|
|
return self.name
|
|
|
|
class Meta:
|
|
verbose_name = _("Tag")
|
|
verbose_name_plural = _("Tags")
|
|
|
|
|
|
class Comment(models.Model):
|
|
text = models.CharField(max_length=255)
|
|
|
|
def __str__(self) -> str:
|
|
return self.text
|
|
|
|
|
|
class BaseComment(polymorphic.PolymorphicModel):
|
|
comments = models.ManyToManyField(Comment)
|
|
|
|
|
|
class Post(BaseComment):
|
|
title = models.CharField(max_length=255)
|
|
desc = models.TextField()
|
|
image = models.ImageField(upload_to="posts/", blank=True)
|
|
tags = models.ManyToManyField(Tags)
|
|
|
|
def __str__(self):
|
|
return self.title
|
|
|
|
|
|
class FrontendTranslation(BaseComment):
|
|
key = models.CharField(max_length=255, unique=True)
|
|
value = models.TextField()
|
|
|
|
def __str__(self):
|
|
return self.key
|
|
|
|
class Meta:
|
|
verbose_name = _("Frontend Translation")
|
|
verbose_name_plural = _("Frontend Translations")
|