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 7d7ebe1c0c
commit f000c492e8
18 changed files with 314 additions and 15 deletions

View File

@@ -5,7 +5,7 @@ from django.http import HttpRequest, HttpResponse, Http404
from django.template.loader import render_to_string
from django.core.exceptions import PermissionDenied
from .models import ChangeSet, CommentThread, Comment
from .models import ChangeSet, HistoricalCommentThread, Comment
from .notifications import NotificationDispatcher
from .state_machine import ApprovalStateMachine
@@ -16,7 +16,7 @@ def get_comments(request: HttpRequest) -> HttpResponse:
if not anchor:
raise Http404("Anchor parameter is required")
thread = CommentThread.objects.filter(anchor__id=anchor).first()
thread = HistoricalCommentThread.objects.filter(anchor__id=anchor).first()
comments = thread.comments.all() if thread else []
return render(request, 'history_tracking/partials/comments_list.html', {
@@ -44,7 +44,7 @@ def add_comment(request: HttpRequest) -> HttpResponse:
if not content:
return HttpResponse("Comment content is required", status=400)
thread, created = CommentThread.objects.get_or_create(
thread, created = HistoricalCommentThread.objects.get_or_create(
anchor={'id': anchor},
defaults={'created_by': request.user}
)