diff options
author | Rémy Coutable <remy@rymai.me> | 2016-01-13 16:37:17 +0100 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2016-01-13 16:37:17 +0100 |
commit | 5efbfa14d4666655edd6d79a3a352a134382b664 (patch) | |
tree | 9403dc20882c9285e6dfc09bb9da66e6da30dc15 | |
parent | 9d7f88c12258e27a189e8229090920db0627e88b (diff) | |
download | gitlab-ce-5efbfa14d4666655edd6d79a3a352a134382b664.tar.gz |
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.
-rw-r--r-- | app/models/note.rb | 4 | ||||
-rw-r--r-- | app/views/projects/notes/_notes.html.haml | 5 |
2 files changed, 8 insertions, 1 deletions
diff --git a/app/models/note.rb b/app/models/note.rb index 3d5b663c99f..3e1375e5ad6 100644 --- a/app/models/note.rb +++ b/app/models/note.rb @@ -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 diff --git a/app/views/projects/notes/_notes.html.haml b/app/views/projects/notes/_notes.html.haml index a4ff947c656..62db86fb181 100644 --- a/app/views/projects/notes/_notes.html.haml +++ b/app/views/projects/notes/_notes.html.haml @@ -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 |