mirror of
https://github.com/pacnpal/thrillwiki_django_no_react.git
synced 2025-12-21 07:11:08 -05:00
Add comments app with models, views, and tests; integrate comments into existing models
This commit is contained in:
@@ -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}
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user