From d294d7585ccfc36629f6fd2d5ac826e64a091148 Mon Sep 17 00:00:00 2001
From: "p.tessenow"
Date: Thu, 23 Sep 2010 09:06:00 +0000
Subject: [PATCH] display link to cost object only if the user has the
permission to see cost_objects in our results table
git-svn-id: https://dev.finn.de/svn/cockpit/branches/reporting_merge@1790 7926756e-e54e-46e6-9721-ed318f58905e
---
app/helpers/reporting_helper.rb | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/app/helpers/reporting_helper.rb b/app/helpers/reporting_helper.rb
index 899b3219e5..a54b86e21e 100644
--- a/app/helpers/reporting_helper.rb
+++ b/app/helpers/reporting_helper.rb
@@ -66,6 +66,15 @@ module ReportingHelper
@show_row[key][value] ||= field_representation_map(key, value)
end
+ def cost_object_link(cost_object_id)
+ co = CostObject.find(cost_object_id)
+ if User.current.allowed_to_with_inheritance?(:view_cost_objects, co.project)
+ link_to_cost_object(co)
+ else
+ co.subject
+ end
+ end
+
def field_representation_map(key, value)
return l(:label_none) if value.blank?
case key.to_sym
@@ -77,7 +86,7 @@ module ReportingHelper
when :tmonth then month_name(value.to_i)
when :category_id then IssueCategory.find(value.to_i).name
when :cost_type_id then mapped value, CostType, l(:caption_labor)
- when :cost_object_id then link_to_cost_object CostObject.find(value.to_i)
+ when :cost_object_id then cost_object_link value
when :issue_id then link_to_issue Issue.find(value.to_i)
when :spent_on then format_date(value.to_date)
when :tracker_id then Tracker.find(value.to_i)