mirror of
https://github.com/pacnpal/thrillwiki_django_no_react.git
synced 2025-12-20 18:31:09 -05:00
Refactor comments app to use mixins for comment functionality; update admin interfaces and add historical model fixes
This commit is contained in:
17
comments/mixins.py
Normal file
17
comments/mixins.py
Normal 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)
|
||||
Reference in New Issue
Block a user