##// END OF EJS Templates
tracker filter added on change log...
Jean-Philippe Lang -
r16:6b08e1b3155e
parent child
Show More
@@ -1,296 +1,305
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 ProjectsController < ApplicationController
18 class ProjectsController < ApplicationController
19 layout 'base'
19 layout 'base'
20 before_filter :find_project, :authorize, :except => [ :index, :list, :add ]
20 before_filter :find_project, :authorize, :except => [ :index, :list, :add ]
21 before_filter :require_admin, :only => [ :add, :destroy ]
21 before_filter :require_admin, :only => [ :add, :destroy ]
22
22
23 helper :sort
23 helper :sort
24 include SortHelper
24 include SortHelper
25 helper :search_filter
25 helper :search_filter
26 include SearchFilterHelper
26 include SearchFilterHelper
27 helper :custom_fields
27 helper :custom_fields
28 include CustomFieldsHelper
28 include CustomFieldsHelper
29
29
30 def index
30 def index
31 list
31 list
32 render :action => 'list'
32 render :action => 'list'
33 end
33 end
34
34
35 # Lists public projects
35 # Lists public projects
36 def list
36 def list
37 sort_init 'name', 'asc'
37 sort_init 'name', 'asc'
38 sort_update
38 sort_update
39 @project_count = Project.count(["is_public=?", true])
39 @project_count = Project.count(["is_public=?", true])
40 @project_pages = Paginator.new self, @project_count,
40 @project_pages = Paginator.new self, @project_count,
41 15,
41 15,
42 @params['page']
42 @params['page']
43 @projects = Project.find :all, :order => sort_clause,
43 @projects = Project.find :all, :order => sort_clause,
44 :conditions => ["is_public=?", true],
44 :conditions => ["is_public=?", true],
45 :limit => @project_pages.items_per_page,
45 :limit => @project_pages.items_per_page,
46 :offset => @project_pages.current.offset
46 :offset => @project_pages.current.offset
47 end
47 end
48
48
49 # Add a new project
49 # Add a new project
50 def add
50 def add
51 @custom_fields = IssueCustomField.find(:all)
51 @custom_fields = IssueCustomField.find(:all)
52 @root_projects = Project.find(:all, :conditions => "parent_id is null")
52 @root_projects = Project.find(:all, :conditions => "parent_id is null")
53 @project = Project.new(params[:project])
53 @project = Project.new(params[:project])
54 if request.get?
54 if request.get?
55 @custom_values = ProjectCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @project) }
55 @custom_values = ProjectCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @project) }
56 else
56 else
57 @project.custom_fields = CustomField.find(@params[:custom_field_ids]) if @params[:custom_field_ids]
57 @project.custom_fields = CustomField.find(@params[:custom_field_ids]) if @params[:custom_field_ids]
58 @custom_values = ProjectCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @project, :value => params["custom_fields"][x.id.to_s]) }
58 @custom_values = ProjectCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @project, :value => params["custom_fields"][x.id.to_s]) }
59 @project.custom_values = @custom_values
59 @project.custom_values = @custom_values
60 if @project.save
60 if @project.save
61 flash[:notice] = l(:notice_successful_create)
61 flash[:notice] = l(:notice_successful_create)
62 redirect_to :controller => 'admin', :action => 'projects'
62 redirect_to :controller => 'admin', :action => 'projects'
63 end
63 end
64 end
64 end
65 end
65 end
66
66
67 # Show @project
67 # Show @project
68 def show
68 def show
69 @custom_values = @project.custom_values.find(:all, :include => :custom_field)
69 @custom_values = @project.custom_values.find(:all, :include => :custom_field)
70 @members = @project.members.find(:all, :include => [:user, :role])
70 @members = @project.members.find(:all, :include => [:user, :role])
71 @subprojects = @project.children if @project.children_count > 0
71 @subprojects = @project.children if @project.children_count > 0
72 @news = @project.news.find(:all, :limit => 5, :include => [ :author, :project ], :order => "news.created_on DESC")
72 @news = @project.news.find(:all, :limit => 5, :include => [ :author, :project ], :order => "news.created_on DESC")
73 @trackers = Tracker.find(:all)
73 @trackers = Tracker.find(:all)
74 end
74 end
75
75
76 def settings
76 def settings
77 @root_projects = Project::find(:all, :conditions => ["parent_id is null and id <> ?", @project.id])
77 @root_projects = Project::find(:all, :conditions => ["parent_id is null and id <> ?", @project.id])
78 @custom_fields = IssueCustomField::find_all
78 @custom_fields = IssueCustomField::find_all
79 @issue_category ||= IssueCategory.new
79 @issue_category ||= IssueCategory.new
80 @member ||= @project.members.new
80 @member ||= @project.members.new
81 @roles = Role.find_all
81 @roles = Role.find_all
82 @users = User.find_all - @project.members.find(:all, :include => :user).collect{|m| m.user }
82 @users = User.find_all - @project.members.find(:all, :include => :user).collect{|m| m.user }
83 @custom_values = ProjectCustomField.find(:all).collect { |x| @project.custom_values.find_by_custom_field_id(x.id) || CustomValue.new(:custom_field => x) }
83 @custom_values = ProjectCustomField.find(:all).collect { |x| @project.custom_values.find_by_custom_field_id(x.id) || CustomValue.new(:custom_field => x) }
84 end
84 end
85
85
86 # Edit @project
86 # Edit @project
87 def edit
87 def edit
88 if request.post?
88 if request.post?
89 @project.custom_fields = IssueCustomField.find(@params[:custom_field_ids]) if @params[:custom_field_ids]
89 @project.custom_fields = IssueCustomField.find(@params[:custom_field_ids]) if @params[:custom_field_ids]
90 if params[:custom_fields]
90 if params[:custom_fields]
91 @custom_values = ProjectCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @project, :value => params["custom_fields"][x.id.to_s]) }
91 @custom_values = ProjectCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @project, :value => params["custom_fields"][x.id.to_s]) }
92 @project.custom_values = @custom_values
92 @project.custom_values = @custom_values
93 end
93 end
94 if @project.update_attributes(params[:project])
94 if @project.update_attributes(params[:project])
95 flash[:notice] = l(:notice_successful_update)
95 flash[:notice] = l(:notice_successful_update)
96 redirect_to :action => 'settings', :id => @project
96 redirect_to :action => 'settings', :id => @project
97 else
97 else
98 settings
98 settings
99 render :action => 'settings'
99 render :action => 'settings'
100 end
100 end
101 end
101 end
102 end
102 end
103
103
104 # Delete @project
104 # Delete @project
105 def destroy
105 def destroy
106 if request.post? and params[:confirm]
106 if request.post? and params[:confirm]
107 @project.destroy
107 @project.destroy
108 redirect_to :controller => 'admin', :action => 'projects'
108 redirect_to :controller => 'admin', :action => 'projects'
109 end
109 end
110 end
110 end
111
111
112 # Add a new issue category to @project
112 # Add a new issue category to @project
113 def add_issue_category
113 def add_issue_category
114 if request.post?
114 if request.post?
115 @issue_category = @project.issue_categories.build(params[:issue_category])
115 @issue_category = @project.issue_categories.build(params[:issue_category])
116 if @issue_category.save
116 if @issue_category.save
117 flash[:notice] = l(:notice_successful_create)
117 flash[:notice] = l(:notice_successful_create)
118 redirect_to :action => 'settings', :id => @project
118 redirect_to :action => 'settings', :id => @project
119 else
119 else
120 settings
120 settings
121 render :action => 'settings'
121 render :action => 'settings'
122 end
122 end
123 end
123 end
124 end
124 end
125
125
126 # Add a new version to @project
126 # Add a new version to @project
127 def add_version
127 def add_version
128 @version = @project.versions.build(params[:version])
128 @version = @project.versions.build(params[:version])
129 if request.post? and @version.save
129 if request.post? and @version.save
130 flash[:notice] = l(:notice_successful_create)
130 flash[:notice] = l(:notice_successful_create)
131 redirect_to :action => 'settings', :id => @project
131 redirect_to :action => 'settings', :id => @project
132 end
132 end
133 end
133 end
134
134
135 # Add a new member to @project
135 # Add a new member to @project
136 def add_member
136 def add_member
137 @member = @project.members.build(params[:member])
137 @member = @project.members.build(params[:member])
138 if request.post?
138 if request.post?
139 if @member.save
139 if @member.save
140 flash[:notice] = l(:notice_successful_create)
140 flash[:notice] = l(:notice_successful_create)
141 redirect_to :action => 'settings', :id => @project
141 redirect_to :action => 'settings', :id => @project
142 else
142 else
143 settings
143 settings
144 render :action => 'settings'
144 render :action => 'settings'
145 end
145 end
146 end
146 end
147 end
147 end
148
148
149 # Show members list of @project
149 # Show members list of @project
150 def list_members
150 def list_members
151 @members = @project.members
151 @members = @project.members
152 end
152 end
153
153
154 # Add a new document to @project
154 # Add a new document to @project
155 def add_document
155 def add_document
156 @categories = Enumeration::get_values('DCAT')
156 @categories = Enumeration::get_values('DCAT')
157 @document = @project.documents.build(params[:document])
157 @document = @project.documents.build(params[:document])
158 if request.post?
158 if request.post?
159 # Save the attachment
159 # Save the attachment
160 if params[:attachment][:file].size > 0
160 if params[:attachment][:file].size > 0
161 @attachment = @document.attachments.build(params[:attachment])
161 @attachment = @document.attachments.build(params[:attachment])
162 @attachment.author_id = self.logged_in_user.id if self.logged_in_user
162 @attachment.author_id = self.logged_in_user.id if self.logged_in_user
163 end
163 end
164 if @document.save
164 if @document.save
165 flash[:notice] = l(:notice_successful_create)
165 flash[:notice] = l(:notice_successful_create)
166 redirect_to :action => 'list_documents', :id => @project
166 redirect_to :action => 'list_documents', :id => @project
167 end
167 end
168 end
168 end
169 end
169 end
170
170
171 # Show documents list of @project
171 # Show documents list of @project
172 def list_documents
172 def list_documents
173 @documents = @project.documents
173 @documents = @project.documents
174 end
174 end
175
175
176 # Add a new issue to @project
176 # Add a new issue to @project
177 def add_issue
177 def add_issue
178 @tracker = Tracker.find(params[:tracker_id])
178 @tracker = Tracker.find(params[:tracker_id])
179 @priorities = Enumeration::get_values('IPRI')
179 @priorities = Enumeration::get_values('IPRI')
180 @issue = Issue.new(:project => @project, :tracker => @tracker)
180 @issue = Issue.new(:project => @project, :tracker => @tracker)
181 if request.get?
181 if request.get?
182 @custom_values = @project.custom_fields_for_issues(@tracker).collect { |x| CustomValue.new(:custom_field => x, :customized => @issue) }
182 @custom_values = @project.custom_fields_for_issues(@tracker).collect { |x| CustomValue.new(:custom_field => x, :customized => @issue) }
183 else
183 else
184 @issue.attributes = params[:issue]
184 @issue.attributes = params[:issue]
185 @issue.author_id = self.logged_in_user.id if self.logged_in_user
185 @issue.author_id = self.logged_in_user.id if self.logged_in_user
186 # Create the document if a file was sent
186 # Create the document if a file was sent
187 if params[:attachment][:file].size > 0
187 if params[:attachment][:file].size > 0
188 @attachment = @issue.attachments.build(params[:attachment])
188 @attachment = @issue.attachments.build(params[:attachment])
189 @attachment.author_id = self.logged_in_user.id if self.logged_in_user
189 @attachment.author_id = self.logged_in_user.id if self.logged_in_user
190 end
190 end
191 @custom_values = @project.custom_fields_for_issues(@tracker).collect { |x| CustomValue.new(:custom_field => x, :customized => @issue, :value => params["custom_fields"][x.id.to_s]) }
191 @custom_values = @project.custom_fields_for_issues(@tracker).collect { |x| CustomValue.new(:custom_field => x, :customized => @issue, :value => params["custom_fields"][x.id.to_s]) }
192 @issue.custom_values = @custom_values
192 @issue.custom_values = @custom_values
193 if @issue.save
193 if @issue.save
194 flash[:notice] = l(:notice_successful_create)
194 flash[:notice] = l(:notice_successful_create)
195 Mailer.deliver_issue_add(@issue) if Permission.find_by_controller_and_action(@params[:controller], @params[:action]).mail_enabled?
195 Mailer.deliver_issue_add(@issue) if Permission.find_by_controller_and_action(@params[:controller], @params[:action]).mail_enabled?
196 redirect_to :action => 'list_issues', :id => @project
196 redirect_to :action => 'list_issues', :id => @project
197 end
197 end
198 end
198 end
199 end
199 end
200
200
201 # Show filtered/sorted issues list of @project
201 # Show filtered/sorted issues list of @project
202 def list_issues
202 def list_issues
203 sort_init 'issues.id', 'desc'
203 sort_init 'issues.id', 'desc'
204 sort_update
204 sort_update
205
205
206 search_filter_init_list_issues
206 search_filter_init_list_issues
207 search_filter_update if params[:set_filter] or request.post?
207 search_filter_update if params[:set_filter] or request.post?
208
208
209 @issue_count = Issue.count(:include => [:status, :project], :conditions => search_filter_clause)
209 @issue_count = Issue.count(:include => [:status, :project], :conditions => search_filter_clause)
210 @issue_pages = Paginator.new self, @issue_count, 15, @params['page']
210 @issue_pages = Paginator.new self, @issue_count, 15, @params['page']
211 @issues = Issue.find :all, :order => sort_clause,
211 @issues = Issue.find :all, :order => sort_clause,
212 :include => [ :author, :status, :tracker, :project ],
212 :include => [ :author, :status, :tracker, :project ],
213 :conditions => search_filter_clause,
213 :conditions => search_filter_clause,
214 :limit => @issue_pages.items_per_page,
214 :limit => @issue_pages.items_per_page,
215 :offset => @issue_pages.current.offset
215 :offset => @issue_pages.current.offset
216 end
216 end
217
217
218 # Export filtered/sorted issues list to CSV
218 # Export filtered/sorted issues list to CSV
219 def export_issues_csv
219 def export_issues_csv
220 sort_init 'issues.id', 'desc'
220 sort_init 'issues.id', 'desc'
221 sort_update
221 sort_update
222
222
223 search_filter_init_list_issues
223 search_filter_init_list_issues
224
224
225 @issues = Issue.find :all, :order => sort_clause,
225 @issues = Issue.find :all, :order => sort_clause,
226 :include => [ :author, :status, :tracker, :project ],
226 :include => [ :author, :status, :tracker, :project ],
227 :conditions => search_filter_clause
227 :conditions => search_filter_clause
228
228
229 export = StringIO.new
229 export = StringIO.new
230 CSV::Writer.generate(export, ',') do |csv|
230 CSV::Writer.generate(export, ',') do |csv|
231 csv << %w(Id Status Tracker Subject Author Created Updated)
231 csv << %w(Id Status Tracker Subject Author Created Updated)
232 @issues.each do |issue|
232 @issues.each do |issue|
233 csv << [issue.id, issue.status.name, issue.tracker.name, issue.subject, issue.author.display_name, l_datetime(issue.created_on), l_datetime(issue.updated_on)]
233 csv << [issue.id, issue.status.name, issue.tracker.name, issue.subject, issue.author.display_name, l_datetime(issue.created_on), l_datetime(issue.updated_on)]
234 end
234 end
235 end
235 end
236 export.rewind
236 export.rewind
237 send_data(export.read,
237 send_data(export.read,
238 :type => 'text/csv; charset=utf-8; header=present',
238 :type => 'text/csv; charset=utf-8; header=present',
239 :filename => 'export.csv')
239 :filename => 'export.csv')
240 end
240 end
241
241
242 # Add a news to @project
242 # Add a news to @project
243 def add_news
243 def add_news
244 @news = News.new(:project => @project)
244 @news = News.new(:project => @project)
245 if request.post?
245 if request.post?
246 @news.attributes = params[:news]
246 @news.attributes = params[:news]
247 @news.author_id = self.logged_in_user.id if self.logged_in_user
247 @news.author_id = self.logged_in_user.id if self.logged_in_user
248 if @news.save
248 if @news.save
249 flash[:notice] = l(:notice_successful_create)
249 flash[:notice] = l(:notice_successful_create)
250 redirect_to :action => 'list_news', :id => @project
250 redirect_to :action => 'list_news', :id => @project
251 end
251 end
252 end
252 end
253 end
253 end
254
254
255 # Show news list of @project
255 # Show news list of @project
256 def list_news
256 def list_news
257 @news_pages, @news = paginate :news, :per_page => 10, :conditions => ["project_id=?", @project.id], :include => :author, :order => "news.created_on DESC"
257 @news_pages, @news = paginate :news, :per_page => 10, :conditions => ["project_id=?", @project.id], :include => :author, :order => "news.created_on DESC"
258 end
258 end
259
259
260 def add_file
260 def add_file
261 if request.post?
261 if request.post?
262 # Save the attachment
262 # Save the attachment
263 if params[:attachment][:file].size > 0
263 if params[:attachment][:file].size > 0
264 @attachment = @project.versions.find(params[:version_id]).attachments.build(params[:attachment])
264 @attachment = @project.versions.find(params[:version_id]).attachments.build(params[:attachment])
265 @attachment.author_id = self.logged_in_user.id if self.logged_in_user
265 @attachment.author_id = self.logged_in_user.id if self.logged_in_user
266 if @attachment.save
266 if @attachment.save
267 flash[:notice] = l(:notice_successful_create)
267 flash[:notice] = l(:notice_successful_create)
268 redirect_to :controller => 'projects', :action => 'list_files', :id => @project
268 redirect_to :controller => 'projects', :action => 'list_files', :id => @project
269 end
269 end
270 end
270 end
271 end
271 end
272 @versions = @project.versions
272 @versions = @project.versions
273 end
273 end
274
274
275 def list_files
275 def list_files
276 @versions = @project.versions
276 @versions = @project.versions
277 end
277 end
278
278
279 # Show changelog of @project
279 # Show changelog for @project
280 def changelog
280 def changelog
281 @trackers = Tracker.find(:all, :conditions => ["is_in_chlog=?", true])
282 if request.get?
283 @selected_tracker_ids = @trackers.collect {|t| t.id.to_s }
284 else
285 @selected_tracker_ids = params[:tracker_ids].collect { |id| id.to_i.to_s } if params[:tracker_ids] and params[:tracker_ids].is_a? Array
286 end
287 @selected_tracker_ids ||= []
281 @fixed_issues = @project.issues.find(:all,
288 @fixed_issues = @project.issues.find(:all,
282 :include => [ :fixed_version, :status, :tracker ],
289 :include => [ :fixed_version, :status, :tracker ],
283 :conditions => [ "issue_statuses.is_closed=? and trackers.is_in_chlog=? and issues.fixed_version_id is not null", true, true]
290 :conditions => [ "issue_statuses.is_closed=? and issues.tracker_id in (#{@selected_tracker_ids.join(',')}) and issues.fixed_version_id is not null", true],
284 )
291 :order => "versions.effective_date DESC, issues.id DESC"
292 ) unless @selected_tracker_ids.empty?
293 @fixed_issues ||= []
285 end
294 end
286
295
287 private
296 private
288 # Find project of id params[:id]
297 # Find project of id params[:id]
289 # if not found, redirect to project list
298 # if not found, redirect to project list
290 # used as a before_filter
299 # Used as a before_filter
291 def find_project
300 def find_project
292 @project = Project.find(params[:id])
301 @project = Project.find(params[:id])
293 rescue
302 rescue
294 redirect_to :action => 'list'
303 redirect_to :action => 'list'
295 end
304 end
296 end
305 end
@@ -1,12 +1,25
1 <h2><%=l(:label_change_log)%></h2>
1 <h2><%=l(:label_change_log)%></h2>
2
2
3 <% fixed_issues = @fixed_issues.group_by {|i| i.fixed_version } %>
3
4 <% fixed_issues.each do |version, issues| %>
4 <%= start_form_tag %>
5 <p><strong><%= version.name %></strong> - <%= format_date(version.effective_date) %><br />
5 <% @trackers.each do |tracker| %>
6 <%=h version.description %></p>
6 <%= check_box_tag "tracker_ids[]", tracker.id, (@selected_tracker_ids.include? tracker.id.to_s) %>
7 <ul>
7 <%= tracker.name %>
8 <% issues.each do |i| %>
9 <li><%= link_to i.long_id, :controller => 'issues', :action => 'show', :id => i %> [<%= i.tracker.name %>]: <%= i.subject %></li>
10 <% end %>
11 </ul>
12 <% end %>
8 <% end %>
9 &nbsp;&nbsp;<%= submit_tag l(:button_apply), :class => 'button-small' %>
10 <%= end_form_tag %>
11
12 <p>&nbsp;</p>
13
14 <% ver_id = nil
15 @fixed_issues.each do |issue| %>
16 <% unless ver_id == issue.fixed_version_id %>
17 <% if ver_id %></ul><% end %>
18 <p><strong><%= issue.fixed_version.name %></strong> - <%= format_date(issue.fixed_version.effective_date) %><br />
19 <%=h issue.fixed_version.description %></p>
20 <ul>
21 <% ver_id = issue.fixed_version_id
22 end %>
23 <li><%= link_to issue.long_id, :controller => 'issues', :action => 'show', :id => issue %> [<%= issue.tracker.name %>]: <%= issue.subject %></li>
24 <% end %>
25
General Comments 0
You need to be logged in to leave comments. Login now