Commit 5efbfa14 authored by Rémy Coutable's avatar Rémy Coutable

Move complex view condition to a model method

This is moved to a model method rather than an helper method because the
API will need it too.
parent 9d7f88c1
......@@ -358,6 +358,10 @@ class Note < ActiveRecord::Base
!system? && !is_award
end
def cross_reference_not_visible_for?(user)
cross_reference? && referenced_mentionables(user).empty?
end
# Checks if note is an award added as a comment
#
# If note is an award, this method sets is_award to true
......
......@@ -2,11 +2,14 @@
- @discussions.each do |discussion_notes|
- note = discussion_notes.first
- if note_for_main_target?(note)
- next if note.cross_reference_not_visible_for?(current_user)
= render discussion_notes
- else
= render 'projects/notes/discussion', discussion_notes: discussion_notes
- else
- @notes.each do |note|
- next unless note.author
- next if note.cross_reference? && note.referenced_mentionables(current_user).empty?
- next if note.cross_reference_not_visible_for?(current_user)
= render note
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment