Add comments app with models, views, and tests; integrate comments into existing models

This commit is contained in:
pacnpal
2025-02-07 21:58:02 -05:00
parent 86ae24bbac
commit 75f5b07129
18 changed files with 314 additions and 15 deletions

View File

@@ -2,6 +2,7 @@ from django.db import models
from django.utils.text import slugify
from django.urls import reverse
from django.contrib.contenttypes.models import ContentType
from django.contrib.contenttypes.fields import GenericRelation
from typing import Tuple, Optional, ClassVar, TYPE_CHECKING
from history_tracking.models import HistoricalModel, VersionBranch, ChangeSet
from history_tracking.signals import get_current_branch, ChangesetContextManager
@@ -19,6 +20,10 @@ class Company(HistoricalModel):
total_rides = models.IntegerField(default=0)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
comments = GenericRelation('comments.CommentThread',
related_name='company_threads',
related_query_name='comments_thread'
)
objects: ClassVar[models.Manager['Company']]
@@ -101,6 +106,10 @@ class Manufacturer(HistoricalModel):
total_roller_coasters = models.IntegerField(default=0)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
comments = GenericRelation('comments.CommentThread',
related_name='manufacturer_threads',
related_query_name='comments_thread'
)
objects: ClassVar[models.Manager['Manufacturer']]
@@ -181,6 +190,10 @@ class Designer(HistoricalModel):
total_roller_coasters = models.IntegerField(default=0)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
comments = GenericRelation('comments.CommentThread',
related_name='designer_threads',
related_query_name='comments_thread'
)
objects: ClassVar[models.Manager['Designer']]