]> source.dussan.org Git - redmine.git/commitdiff
Moves relations fetching from views to the controller and skip invalid relations...
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 22 Jan 2011 13:28:20 +0000 (13:28 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 22 Jan 2011 13:28:20 +0000 (13:28 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4741 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/issues_controller.rb
app/views/issues/_relations.rhtml
app/views/issues/show.api.rsb

index 3d1dbe9f1b31550f9e434f95951224248fc28300..051f89107e0212ad8e2fbbd603dd2d5532b2302d 100644 (file)
@@ -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
index 5b27fa6a577e3a3c7a63887d627601bd9f6948cc..f8535b827b77921697aca4f0a7510c3bd225587c 100644 (file)
@@ -6,9 +6,9 @@
 
 <p><strong><%=l(:label_related_issues)%></strong></p>
 
-<% if @issue.relations.any? %>
+<% if @relations.present? %>
 <table style="width:100%">
-<% @issue.relations.select {|r| r.other_issue(@issue).visible? }.each do |relation| %>
+<% @relations.each do |relation| %>
 <tr>
 <td><%= 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? %>
index a6461ff83e6c3f365b436033369c03fca34894b5..170aeb37555712a079b10320df433458f9f9b172 100644 (file)
@@ -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|