mirror of
https://github.com/pacnpal/thrillwiki_django_no_react.git
synced 2025-12-21 03:31:08 -05:00
Add comments app with models, views, and tests; integrate comments into existing models
This commit is contained in:
@@ -18,7 +18,8 @@ class HistoricalModel(models.Model):
|
||||
id = models.BigAutoField(primary_key=True)
|
||||
history: HistoricalRecords = HistoricalRecords(
|
||||
inherit=True,
|
||||
bases=(HistoricalChangeMixin,)
|
||||
bases=(HistoricalChangeMixin,),
|
||||
excluded_fields=['comments', 'photos', 'reviews'] # Exclude all generic relations
|
||||
)
|
||||
|
||||
class Meta:
|
||||
@@ -116,8 +117,8 @@ class VersionTag(models.Model):
|
||||
def __str__(self) -> str:
|
||||
return f"{self.name} ({self.branch.name})"
|
||||
|
||||
class CommentThread(models.Model):
|
||||
"""Represents a thread of comments on a historical record"""
|
||||
class HistoricalCommentThread(models.Model):
|
||||
"""Represents a thread of comments specific to historical records and version control"""
|
||||
content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE)
|
||||
object_id = models.PositiveIntegerField()
|
||||
content_object = GenericForeignKey('content_type', 'object_id')
|
||||
@@ -149,7 +150,7 @@ class CommentThread(models.Model):
|
||||
|
||||
class Comment(models.Model):
|
||||
"""Individual comment within a thread"""
|
||||
thread = models.ForeignKey(CommentThread, on_delete=models.CASCADE, related_name='comments')
|
||||
thread = models.ForeignKey(HistoricalCommentThread, on_delete=models.CASCADE, related_name='comments')
|
||||
author = models.ForeignKey(User, on_delete=models.SET_NULL, null=True)
|
||||
content = models.TextField()
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
|
||||
Reference in New Issue
Block a user