Skip to content

Commit

Permalink
fix(comment): validate comment body is required
Browse files Browse the repository at this point in the history
  • Loading branch information
Hojagulyyev committed Dec 27, 2023
1 parent 3bd2187 commit ee8ead9
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion apps/diaries/interactors.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,13 @@ def create_comment(request, diary_id: int):

# ===== VALIDATION

if not body:
messages.error(request, message="comment body is required")
return redirect(
f"{reverse(viewname='diaries:detail_view', kwargs={'id': diary.id})}"
f"?body={body}&on_comments_tab=1"
)

if (
DiaryComment.objects
.filter(
Expand All @@ -83,7 +90,7 @@ def create_comment(request, diary_id: int):
messages.error(request, message="this comment already exists for today")
return redirect(
f"{reverse(viewname='diaries:detail_view', kwargs={'id': diary.id})}"
f"?body={body}"
f"?body={body}&on_comments_tab=1"
)

# ===== PROCESS
Expand Down

0 comments on commit ee8ead9

Please sign in to comment.