##// END OF EJS Templates
Refactored IssueStatus finder to a before_filter...
Eric Davis -
r3296:937d0c70f770
parent child
Show More
@@ -1,94 +1,95
1 # redMine - project management software
1 # redMine - project management software
2 # Copyright (C) 2006 Jean-Philippe Lang
2 # Copyright (C) 2006 Jean-Philippe Lang
3 #
3 #
4 # This program is free software; you can redistribute it and/or
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
7 # of the License, or (at your option) any later version.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU General Public License
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
17
18 class ReportsController < ApplicationController
18 class ReportsController < ApplicationController
19 menu_item :issues
19 menu_item :issues
20 before_filter :find_project, :authorize
20 before_filter :find_project, :authorize, :find_issue_statuses
21
21
22 def issue_report
22 def issue_report
23 @statuses = IssueStatus.find(:all, :order => 'position')
24
25 @trackers = @project.trackers
23 @trackers = @project.trackers
26 @versions = @project.shared_versions.sort
24 @versions = @project.shared_versions.sort
27 @priorities = IssuePriority.all
25 @priorities = IssuePriority.all
28 @categories = @project.issue_categories
26 @categories = @project.issue_categories
29 @assignees = @project.members.collect { |m| m.user }.sort
27 @assignees = @project.members.collect { |m| m.user }.sort
30 @authors = @project.members.collect { |m| m.user }.sort
28 @authors = @project.members.collect { |m| m.user }.sort
31 @subprojects = @project.descendants.active
29 @subprojects = @project.descendants.active
32
30
33 @issues_by_tracker = Issue.by_tracker(@project)
31 @issues_by_tracker = Issue.by_tracker(@project)
34 @issues_by_version = Issue.by_version(@project)
32 @issues_by_version = Issue.by_version(@project)
35 @issues_by_priority = Issue.by_priority(@project)
33 @issues_by_priority = Issue.by_priority(@project)
36 @issues_by_category = Issue.by_category(@project)
34 @issues_by_category = Issue.by_category(@project)
37 @issues_by_assigned_to = Issue.by_assigned_to(@project)
35 @issues_by_assigned_to = Issue.by_assigned_to(@project)
38 @issues_by_author = Issue.by_author(@project)
36 @issues_by_author = Issue.by_author(@project)
39 @issues_by_subproject = Issue.by_subproject(@project) || []
37 @issues_by_subproject = Issue.by_subproject(@project) || []
40
38
41 render :template => "reports/issue_report"
39 render :template => "reports/issue_report"
42 end
40 end
43
41
44 def issue_report_details
42 def issue_report_details
45 @statuses = IssueStatus.find(:all, :order => 'position')
46
47 case params[:detail]
43 case params[:detail]
48 when "tracker"
44 when "tracker"
49 @field = "tracker_id"
45 @field = "tracker_id"
50 @rows = @project.trackers
46 @rows = @project.trackers
51 @data = Issue.by_tracker(@project)
47 @data = Issue.by_tracker(@project)
52 @report_title = l(:field_tracker)
48 @report_title = l(:field_tracker)
53 when "version"
49 when "version"
54 @field = "fixed_version_id"
50 @field = "fixed_version_id"
55 @rows = @project.shared_versions.sort
51 @rows = @project.shared_versions.sort
56 @data = Issue.by_version(@project)
52 @data = Issue.by_version(@project)
57 @report_title = l(:field_version)
53 @report_title = l(:field_version)
58 when "priority"
54 when "priority"
59 @field = "priority_id"
55 @field = "priority_id"
60 @rows = IssuePriority.all
56 @rows = IssuePriority.all
61 @data = Issue.by_priority(@project)
57 @data = Issue.by_priority(@project)
62 @report_title = l(:field_priority)
58 @report_title = l(:field_priority)
63 when "category"
59 when "category"
64 @field = "category_id"
60 @field = "category_id"
65 @rows = @project.issue_categories
61 @rows = @project.issue_categories
66 @data = Issue.by_category(@project)
62 @data = Issue.by_category(@project)
67 @report_title = l(:field_category)
63 @report_title = l(:field_category)
68 when "assigned_to"
64 when "assigned_to"
69 @field = "assigned_to_id"
65 @field = "assigned_to_id"
70 @rows = @project.members.collect { |m| m.user }.sort
66 @rows = @project.members.collect { |m| m.user }.sort
71 @data = Issue.by_assigned_to(@project)
67 @data = Issue.by_assigned_to(@project)
72 @report_title = l(:field_assigned_to)
68 @report_title = l(:field_assigned_to)
73 when "author"
69 when "author"
74 @field = "author_id"
70 @field = "author_id"
75 @rows = @project.members.collect { |m| m.user }.sort
71 @rows = @project.members.collect { |m| m.user }.sort
76 @data = Issue.by_author(@project)
72 @data = Issue.by_author(@project)
77 @report_title = l(:field_author)
73 @report_title = l(:field_author)
78 when "subproject"
74 when "subproject"
79 @field = "project_id"
75 @field = "project_id"
80 @rows = @project.descendants.active
76 @rows = @project.descendants.active
81 @data = Issue.by_subproject(@project) || []
77 @data = Issue.by_subproject(@project) || []
82 @report_title = l(:field_subproject)
78 @report_title = l(:field_subproject)
83 end
79 end
84
80
85 respond_to do |format|
81 respond_to do |format|
86 if @field
82 if @field
87 format.html {}
83 format.html {}
88 else
84 else
89 format.html { redirect_to :action => 'issue_report', :id => @project }
85 format.html { redirect_to :action => 'issue_report', :id => @project }
90 end
86 end
91 end
87 end
92 end
88 end
93
89
90 private
91
92 def find_issue_statuses
93 @statuses = IssueStatus.find(:all, :order => 'position')
94 end
94 end
95 end
General Comments 0
You need to be logged in to leave comments. Login now