Refactor comments app to use mixins for comment functionality; update admin interfaces and add historical model fixes

This commit is contained in:
pacnpal
2025-02-08 16:33:55 -05:00
parent f000c492e8
commit 181f49a0f2
21 changed files with 548 additions and 280 deletions

17
comments/mixins.py Normal file
View File

@@ -0,0 +1,17 @@
from django.contrib.contenttypes.fields import GenericRelation
from .models import get_comment_threads
class CommentableMixin:
"""
Mixin for models that should have comment functionality.
Uses composition instead of inheritance to avoid historical model issues.
"""
@property
def comments(self):
"""Get comments helper for this instance."""
if self.__class__.__name__.startswith('Historical'):
# Historical models delegate to their current instance
return self.instance.comments
return get_comment_threads(self)