Add QuestionReview model and link to QuestionBase for enhanced review functionality

This commit is contained in:
Ross
2025-10-22 20:15:20 +01:00
parent 8addc900f5
commit 6d589ef630
+38
View File
@@ -219,6 +219,8 @@ class QuestionBase(models.Model, AuthorMixin, QuestionMixin):
notes = GenericRelation("generic.QuestionNote")
reviews = GenericRelation("generic.QuestionReview")
class Meta:
abstract = True
@@ -1315,6 +1317,42 @@ class NoteType(models.Model):
def __str__(self):
return self.note_type
class QuestionReview(models.Model):
class StatusChoices(models.TextChoices):
ACCEPTED = "AC", "Accepted"
OUTDATED = "OD", "Outdated"
ERROR = "ER", "Error"
REJECTED = "RJ", "Rejected"
content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE)
object_id = models.PositiveIntegerField()
question = GenericForeignKey("content_type", "object_id")
author = models.ForeignKey(
settings.AUTH_USER_MODEL, on_delete=models.CASCADE, blank=True, null=True
)
comment = models.TextField(blank=True)
status = models.CharField(max_length=2, choices=StatusChoices.choices, default=StatusChoices.ACCEPTED)
created_on = models.DateTimeField(auto_now_add=True)
def __str__(self):
return "{}: {} [{}] {}".format(
self.content_type,
self.get_author_str(),
self.created_on,
self.comment,
)
def get_author_str(self):
if self.author is not None:
return self.author.username
else:
return "Unknown"
class QuestionNote(models.Model):
content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE)