Skip to content

Commit

Permalink
style: pre-commit fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pre-commit-ci[bot] committed Jun 23, 2024
1 parent ac54e5a commit c04b14f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
8 changes: 6 additions & 2 deletions eap_backend/eap_api/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,12 @@
# views.comment_list,
# name="comment_list",
# ),
path('assurance_case/<int:assurance_case_id>/comments/', views.comment_list, name='comment_list'),
path('comments/<int:pk>/', views.comment_detail, name='comment_detail'),
path(
"assurance_case/<int:assurance_case_id>/comments/",
views.comment_list,
name="comment_list",
),
path("comments/<int:pk>/", views.comment_detail, name="comment_detail"),
path(
"comments/<int:comment_id>/reply/",
views.reply_to_comment,
Expand Down
12 changes: 7 additions & 5 deletions eap_backend/eap_api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -642,14 +642,16 @@ def comment_list(request, assurance_case_id):

elif request.method == "POST":
data = request.data.copy()
data['assurance_case_id'] = assurance_case_id # Ensure assurance_case_id is set in the data
data["assurance_case_id"] = (
assurance_case_id # Ensure assurance_case_id is set in the data
)
serializer = CommentSerializer(data=data)
if serializer.is_valid():
# Ensure the author is set to the current user
serializer.save(author=request.user)
return Response(serializer.data, status=status.HTTP_201_CREATED)
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)

return JsonResponse(serializer.errors, status=status.HTTP_400_BAD_REQUEST)


Expand All @@ -666,18 +668,18 @@ def comment_detail(request, pk):
if request.method == "GET":
serializer = CommentSerializer(comment)
return Response(serializer.data)

elif request.method == "PUT":
serializer = CommentSerializer(comment, data=request.data, partial=True)
if serializer.is_valid():
serializer.save()
return Response(serializer.data)
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)

elif request.method == "DELETE":
comment.delete()
return HttpResponse(status=204)

return JsonResponse(serializer.errors, status=status.HTTP_400_BAD_REQUEST)


Expand Down
2 changes: 1 addition & 1 deletion next_frontend/components/cases/NotesEditForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const NotesEditForm = ({ note, setEdit } : NotesEditFormProps ) => {
const updatedComment = await response.json();

// Find the index of the updated comment in the existing comments array
const updatedComments = assuranceCase.comments.map((comment:any) =>
const updatedComments = assuranceCase.comments.map((comment:any) =>
comment.id === updatedComment.id ? updatedComment : comment
);

Expand Down
2 changes: 1 addition & 1 deletion next_frontend/components/cases/NotesFeed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export default function NotesFeed({ }) {
) : (
<p className="whitespace-normal">{activityItem.content}</p>
)}

</div>
</div>
{!edit && (
Expand Down

0 comments on commit c04b14f

Please sign in to comment.