From b8dee485ca0474639edbe7173c45cda850e07459 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sat, 22 Jan 2011 13:28:20 +0000 Subject: [PATCH] Moves relations fetching from views to the controller and skip invalid relations (#7385). git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4741 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/issues_controller.rb | 1 + app/views/issues/_relations.rhtml | 4 ++-- app/views/issues/show.api.rsb | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 3d1dbe9f1..051f89107 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -108,6 +108,7 @@ class IssuesController < ApplicationController @journals.reverse! if User.current.wants_comments_in_reverse_order? @changesets = @issue.changesets.visible.all @changesets.reverse! if User.current.wants_comments_in_reverse_order? + @relations = @issue.relations.select {|r| r.other_issue(@issue) && r.other_issue(@issue).visible? } @allowed_statuses = @issue.new_statuses_allowed_to(User.current) @edit_allowed = User.current.allowed_to?(:edit_issues, @project) @priorities = IssuePriority.all diff --git a/app/views/issues/_relations.rhtml b/app/views/issues/_relations.rhtml index 5b27fa6a5..f8535b827 100644 --- a/app/views/issues/_relations.rhtml +++ b/app/views/issues/_relations.rhtml @@ -6,9 +6,9 @@

<%=l(:label_related_issues)%>

-<% if @issue.relations.any? %> +<% if @relations.present? %> -<% @issue.relations.select {|r| r.other_issue(@issue).visible? }.each do |relation| %> +<% @relations.each do |relation| %>
<%= l(relation.label_for(@issue)) %> <%= "(#{l('datetime.distance_in_words.x_days', :count => relation.delay)})" if relation.delay && relation.delay != 0 %> <%= h(relation.other_issue(@issue).project) + ' - ' if Setting.cross_project_issue_relations? %> diff --git a/app/views/issues/show.api.rsb b/app/views/issues/show.api.rsb index a6461ff83..170aeb375 100644 --- a/app/views/issues/show.api.rsb +++ b/app/views/issues/show.api.rsb @@ -26,10 +26,10 @@ api.issue do render_api_issue_children(@issue, api) if include_in_api_response?('children') api.array :relations do - @issue.relations.select {|r| r.other_issue(@issue).visible? }.each do |relation| + @relations.each do |relation| api.relation(:id => relation.id, :issue_id => relation.other_issue(@issue).id, :relation_type => relation.relation_type_for(@issue), :delay => relation.delay) end - end if include_in_api_response?('relations') + end if include_in_api_response?('relations') && @relations.present? api.array :changesets do @issue.changesets.each do |changeset| -- 2.39.5