Skip to content

Commit

Permalink
Add constraint to AnnotationsController
Browse files Browse the repository at this point in the history
  • Loading branch information
Frodo161 committed Nov 4, 2023
1 parent 854470f commit d9674e4
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/controllers/annotations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ def create
@annotation = Annotation.new(annotation_params)

return unless is_valid_color(@annotation.color)
return if @annotation.category_for_database == Annotation.categories[:content] and
@annotation.subcategory.nil?
@annotation.public_comment_id = post_comment(@annotation)

@annotation.user_id = current_user.id
Expand All @@ -50,6 +52,8 @@ def update
@annotation.assign_attributes(annotation_params)

return unless is_valid_color(@annotation.color)
return if @annotation.category_for_database == Annotation.categories[:content] and
@annotation.subcategory.nil?
@annotation.public_comment_id = post_comment(@annotation)

@annotation.save
Expand Down

0 comments on commit d9674e4

Please sign in to comment.