@@ -0,0 +1,5 | |||
|
1 | <% if authorize_for('projects', 'add_issue') %> | |
|
2 | <%= start_form_tag({ :controller => 'projects', :action => 'add_issue', :id => @project }, :method => 'get') %> | |
|
3 | <%= l(:label_issue_new) %>: <%= select_tag 'tracker_id', ("<option></option>" + options_from_collection_for_select(trackers, 'id', 'name')), :onchange => "if (this.value!='') {this.form.submit();}" %> | |
|
4 | <%= end_form_tag %> | |
|
5 | <% end %> |
@@ -1,531 +1,532 | |||
|
1 | 1 | # redMine - project management software |
|
2 | # Copyright (C) 2006 Jean-Philippe Lang | |
|
2 | # Copyright (C) 2006-2007 Jean-Philippe Lang | |
|
3 | 3 | # |
|
4 | 4 | # This program is free software; you can redistribute it and/or |
|
5 | 5 | # modify it under the terms of the GNU General Public License |
|
6 | 6 | # as published by the Free Software Foundation; either version 2 |
|
7 | 7 | # of the License, or (at your option) any later version. |
|
8 | 8 | # |
|
9 | 9 | # This program is distributed in the hope that it will be useful, |
|
10 | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | 12 | # GNU General Public License for more details. |
|
13 | 13 | # |
|
14 | 14 | # You should have received a copy of the GNU General Public License |
|
15 | 15 | # along with this program; if not, write to the Free Software |
|
16 | 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
17 | 17 | |
|
18 | 18 | class ProjectsController < ApplicationController |
|
19 | 19 | layout 'base' |
|
20 | 20 | before_filter :find_project, :authorize, :except => [ :index, :list, :add ] |
|
21 | 21 | before_filter :require_admin, :only => [ :add, :destroy ] |
|
22 | 22 | |
|
23 | 23 | helper :sort |
|
24 | 24 | include SortHelper |
|
25 | 25 | helper :custom_fields |
|
26 | 26 | include CustomFieldsHelper |
|
27 | 27 | helper :ifpdf |
|
28 | 28 | include IfpdfHelper |
|
29 | 29 | helper IssuesHelper |
|
30 | 30 | helper :queries |
|
31 | 31 | include QueriesHelper |
|
32 | 32 | |
|
33 | 33 | def index |
|
34 | 34 | list |
|
35 | 35 | render :action => 'list' unless request.xhr? |
|
36 | 36 | end |
|
37 | 37 | |
|
38 | 38 | # Lists public projects |
|
39 | 39 | def list |
|
40 | 40 | sort_init 'name', 'asc' |
|
41 | 41 | sort_update |
|
42 | 42 | @project_count = Project.count(["is_public=?", true]) |
|
43 | 43 | @project_pages = Paginator.new self, @project_count, |
|
44 | 44 | 15, |
|
45 | 45 | params['page'] |
|
46 | 46 | @projects = Project.find :all, :order => sort_clause, |
|
47 | 47 | :conditions => ["is_public=?", true], |
|
48 | 48 | :limit => @project_pages.items_per_page, |
|
49 | 49 | :offset => @project_pages.current.offset |
|
50 | 50 | |
|
51 | 51 | render :action => "list", :layout => false if request.xhr? |
|
52 | 52 | end |
|
53 | 53 | |
|
54 | 54 | # Add a new project |
|
55 | 55 | def add |
|
56 | 56 | @custom_fields = IssueCustomField.find(:all) |
|
57 | 57 | @root_projects = Project.find(:all, :conditions => "parent_id is null") |
|
58 | 58 | @project = Project.new(params[:project]) |
|
59 | 59 | if request.get? |
|
60 | 60 | @custom_values = ProjectCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @project) } |
|
61 | 61 | else |
|
62 | 62 | @project.custom_fields = CustomField.find(params[:custom_field_ids]) if params[:custom_field_ids] |
|
63 | 63 | @custom_values = ProjectCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @project, :value => params["custom_fields"][x.id.to_s]) } |
|
64 | 64 | @project.custom_values = @custom_values |
|
65 | 65 | if params[:repository_enabled] && params[:repository_enabled] == "1" |
|
66 | 66 | @project.repository = Repository.new |
|
67 | 67 | @project.repository.attributes = params[:repository] |
|
68 | 68 | end |
|
69 | 69 | if @project.save |
|
70 | 70 | flash[:notice] = l(:notice_successful_create) |
|
71 | 71 | redirect_to :controller => 'admin', :action => 'projects' |
|
72 | 72 | end |
|
73 | 73 | end |
|
74 | 74 | end |
|
75 | 75 | |
|
76 | 76 | # Show @project |
|
77 | 77 | def show |
|
78 | 78 | @custom_values = @project.custom_values.find(:all, :include => :custom_field) |
|
79 | 79 | @members = @project.members.find(:all, :include => [:user, :role]) |
|
80 | 80 | @subprojects = @project.children if @project.children_count > 0 |
|
81 | 81 | @news = @project.news.find(:all, :limit => 5, :include => [ :author, :project ], :order => "news.created_on DESC") |
|
82 | 82 | @trackers = Tracker.find(:all) |
|
83 | 83 | end |
|
84 | 84 | |
|
85 | 85 | def settings |
|
86 | 86 | @root_projects = Project::find(:all, :conditions => ["parent_id is null and id <> ?", @project.id]) |
|
87 | 87 | @custom_fields = IssueCustomField.find(:all) |
|
88 | 88 | @issue_category ||= IssueCategory.new |
|
89 | 89 | @member ||= @project.members.new |
|
90 | 90 | @roles = Role.find(:all) |
|
91 | 91 | @users = User.find(:all) - @project.members.find(:all, :include => :user).collect{|m| m.user } |
|
92 | 92 | @custom_values ||= ProjectCustomField.find(:all).collect { |x| @project.custom_values.find_by_custom_field_id(x.id) || CustomValue.new(:custom_field => x) } |
|
93 | 93 | end |
|
94 | 94 | |
|
95 | 95 | # Edit @project |
|
96 | 96 | def edit |
|
97 | 97 | if request.post? |
|
98 | 98 | @project.custom_fields = IssueCustomField.find(params[:custom_field_ids]) if params[:custom_field_ids] |
|
99 | 99 | if params[:custom_fields] |
|
100 | 100 | @custom_values = ProjectCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @project, :value => params["custom_fields"][x.id.to_s]) } |
|
101 | 101 | @project.custom_values = @custom_values |
|
102 | 102 | end |
|
103 | 103 | if params[:repository_enabled] |
|
104 | 104 | case params[:repository_enabled] |
|
105 | 105 | when "0" |
|
106 | 106 | @project.repository = nil |
|
107 | 107 | when "1" |
|
108 | 108 | @project.repository ||= Repository.new |
|
109 | 109 | @project.repository.attributes = params[:repository] |
|
110 | 110 | end |
|
111 | 111 | end |
|
112 | 112 | @project.attributes = params[:project] |
|
113 | 113 | if @project.save |
|
114 | 114 | flash[:notice] = l(:notice_successful_update) |
|
115 | 115 | redirect_to :action => 'settings', :id => @project |
|
116 | 116 | else |
|
117 | 117 | settings |
|
118 | 118 | render :action => 'settings' |
|
119 | 119 | end |
|
120 | 120 | end |
|
121 | 121 | end |
|
122 | 122 | |
|
123 | 123 | # Delete @project |
|
124 | 124 | def destroy |
|
125 | 125 | if request.post? and params[:confirm] |
|
126 | 126 | @project.destroy |
|
127 | 127 | redirect_to :controller => 'admin', :action => 'projects' |
|
128 | 128 | end |
|
129 | 129 | end |
|
130 | 130 | |
|
131 | 131 | # Add a new issue category to @project |
|
132 | 132 | def add_issue_category |
|
133 | 133 | if request.post? |
|
134 | 134 | @issue_category = @project.issue_categories.build(params[:issue_category]) |
|
135 | 135 | if @issue_category.save |
|
136 | 136 | flash[:notice] = l(:notice_successful_create) |
|
137 | 137 | redirect_to :action => 'settings', :id => @project |
|
138 | 138 | else |
|
139 | 139 | settings |
|
140 | 140 | render :action => 'settings' |
|
141 | 141 | end |
|
142 | 142 | end |
|
143 | 143 | end |
|
144 | 144 | |
|
145 | 145 | # Add a new version to @project |
|
146 | 146 | def add_version |
|
147 | 147 | @version = @project.versions.build(params[:version]) |
|
148 | 148 | if request.post? and @version.save |
|
149 | 149 | flash[:notice] = l(:notice_successful_create) |
|
150 | 150 | redirect_to :action => 'settings', :id => @project |
|
151 | 151 | end |
|
152 | 152 | end |
|
153 | 153 | |
|
154 | 154 | # Add a new member to @project |
|
155 | 155 | def add_member |
|
156 | 156 | @member = @project.members.build(params[:member]) |
|
157 | 157 | if request.post? |
|
158 | 158 | if @member.save |
|
159 | 159 | flash[:notice] = l(:notice_successful_create) |
|
160 | 160 | redirect_to :action => 'settings', :id => @project |
|
161 | 161 | else |
|
162 | 162 | settings |
|
163 | 163 | render :action => 'settings' |
|
164 | 164 | end |
|
165 | 165 | end |
|
166 | 166 | end |
|
167 | 167 | |
|
168 | 168 | # Show members list of @project |
|
169 | 169 | def list_members |
|
170 | 170 | @members = @project.members |
|
171 | 171 | end |
|
172 | 172 | |
|
173 | 173 | # Add a new document to @project |
|
174 | 174 | def add_document |
|
175 | 175 | @categories = Enumeration::get_values('DCAT') |
|
176 | 176 | @document = @project.documents.build(params[:document]) |
|
177 | 177 | if request.post? and @document.save |
|
178 | 178 | # Save the attachments |
|
179 | 179 | params[:attachments].each { |a| |
|
180 | 180 | Attachment.create(:container => @document, :file => a, :author => logged_in_user) unless a.size == 0 |
|
181 | 181 | } if params[:attachments] and params[:attachments].is_a? Array |
|
182 | 182 | flash[:notice] = l(:notice_successful_create) |
|
183 | 183 | redirect_to :action => 'list_documents', :id => @project |
|
184 | 184 | end |
|
185 | 185 | end |
|
186 | 186 | |
|
187 | 187 | # Show documents list of @project |
|
188 | 188 | def list_documents |
|
189 | 189 | @documents = @project.documents.find :all, :include => :category |
|
190 | 190 | end |
|
191 | 191 | |
|
192 | 192 | # Add a new issue to @project |
|
193 | 193 | def add_issue |
|
194 | 194 | @tracker = Tracker.find(params[:tracker_id]) |
|
195 | 195 | @priorities = Enumeration::get_values('IPRI') |
|
196 | 196 | @issue = Issue.new(:project => @project, :tracker => @tracker) |
|
197 | 197 | if request.get? |
|
198 | 198 | @issue.start_date = Date.today |
|
199 | 199 | @custom_values = @project.custom_fields_for_issues(@tracker).collect { |x| CustomValue.new(:custom_field => x, :customized => @issue) } |
|
200 | 200 | else |
|
201 | 201 | @issue.attributes = params[:issue] |
|
202 | 202 | @issue.author_id = self.logged_in_user.id if self.logged_in_user |
|
203 | 203 | # Multiple file upload |
|
204 | 204 | @attachments = [] |
|
205 | 205 | params[:attachments].each { |a| |
|
206 | 206 | @attachments << Attachment.new(:container => @issue, :file => a, :author => logged_in_user) unless a.size == 0 |
|
207 | 207 | } if params[:attachments] and params[:attachments].is_a? Array |
|
208 | 208 | @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]) } |
|
209 | 209 | @issue.custom_values = @custom_values |
|
210 | 210 | if @issue.save |
|
211 | 211 | @attachments.each(&:save) |
|
212 | 212 | flash[:notice] = l(:notice_successful_create) |
|
213 | 213 | Mailer.deliver_issue_add(@issue) if Permission.find_by_controller_and_action(params[:controller], params[:action]).mail_enabled? |
|
214 | 214 | redirect_to :action => 'list_issues', :id => @project |
|
215 | 215 | end |
|
216 | 216 | end |
|
217 | 217 | end |
|
218 | 218 | |
|
219 | 219 | # Show filtered/sorted issues list of @project |
|
220 | 220 | def list_issues |
|
221 | 221 | sort_init 'issues.id', 'desc' |
|
222 | 222 | sort_update |
|
223 | 223 | |
|
224 | 224 | retrieve_query |
|
225 | 225 | |
|
226 | 226 | @results_per_page_options = [ 15, 25, 50, 100 ] |
|
227 | 227 | if params[:per_page] and @results_per_page_options.include? params[:per_page].to_i |
|
228 | 228 | @results_per_page = params[:per_page].to_i |
|
229 | 229 | session[:results_per_page] = @results_per_page |
|
230 | 230 | else |
|
231 | 231 | @results_per_page = session[:results_per_page] || 25 |
|
232 | 232 | end |
|
233 | 233 | |
|
234 | 234 | if @query.valid? |
|
235 | 235 | @issue_count = Issue.count(:include => [:status, :project], :conditions => @query.statement) |
|
236 | 236 | @issue_pages = Paginator.new self, @issue_count, @results_per_page, params['page'] |
|
237 | 237 | @issues = Issue.find :all, :order => sort_clause, |
|
238 | 238 | :include => [ :author, :status, :tracker, :project ], |
|
239 | 239 | :conditions => @query.statement, |
|
240 | 240 | :limit => @issue_pages.items_per_page, |
|
241 | 241 | :offset => @issue_pages.current.offset |
|
242 | end | |
|
242 | end | |
|
243 | @trackers = Tracker.find :all | |
|
243 | 244 | render :layout => false if request.xhr? |
|
244 | 245 | end |
|
245 | 246 | |
|
246 | 247 | # Export filtered/sorted issues list to CSV |
|
247 | 248 | def export_issues_csv |
|
248 | 249 | sort_init 'issues.id', 'desc' |
|
249 | 250 | sort_update |
|
250 | 251 | |
|
251 | 252 | retrieve_query |
|
252 | 253 | render :action => 'list_issues' and return unless @query.valid? |
|
253 | 254 | |
|
254 | 255 | @issues = Issue.find :all, :order => sort_clause, |
|
255 | 256 | :include => [ :author, :status, :tracker, :project, :custom_values ], |
|
256 | 257 | :conditions => @query.statement |
|
257 | 258 | |
|
258 | 259 | ic = Iconv.new('ISO-8859-1', 'UTF-8') |
|
259 | 260 | export = StringIO.new |
|
260 | 261 | CSV::Writer.generate(export, l(:general_csv_separator)) do |csv| |
|
261 | 262 | # csv header fields |
|
262 | 263 | headers = [ "#", l(:field_status), l(:field_tracker), l(:field_subject), l(:field_author), l(:field_created_on), l(:field_updated_on) ] |
|
263 | 264 | for custom_field in @project.all_custom_fields |
|
264 | 265 | headers << custom_field.name |
|
265 | 266 | end |
|
266 | 267 | csv << headers.collect {|c| ic.iconv(c) } |
|
267 | 268 | # csv lines |
|
268 | 269 | @issues.each do |issue| |
|
269 | 270 | fields = [issue.id, issue.status.name, issue.tracker.name, issue.subject, issue.author.display_name, l_datetime(issue.created_on), l_datetime(issue.updated_on)] |
|
270 | 271 | for custom_field in @project.all_custom_fields |
|
271 | 272 | fields << (show_value issue.custom_value_for(custom_field)) |
|
272 | 273 | end |
|
273 | 274 | csv << fields.collect {|c| ic.iconv(c.to_s) } |
|
274 | 275 | end |
|
275 | 276 | end |
|
276 | 277 | export.rewind |
|
277 | 278 | send_data(export.read, :type => 'text/csv; header=present', :filename => 'export.csv') |
|
278 | 279 | end |
|
279 | 280 | |
|
280 | 281 | # Export filtered/sorted issues to PDF |
|
281 | 282 | def export_issues_pdf |
|
282 | 283 | sort_init 'issues.id', 'desc' |
|
283 | 284 | sort_update |
|
284 | 285 | |
|
285 | 286 | retrieve_query |
|
286 | 287 | render :action => 'list_issues' and return unless @query.valid? |
|
287 | 288 | |
|
288 | 289 | @issues = Issue.find :all, :order => sort_clause, |
|
289 | 290 | :include => [ :author, :status, :tracker, :project, :custom_values ], |
|
290 | 291 | :conditions => @query.statement |
|
291 | 292 | |
|
292 | 293 | @options_for_rfpdf ||= {} |
|
293 | 294 | @options_for_rfpdf[:file_name] = "export.pdf" |
|
294 | 295 | render :layout => false |
|
295 | 296 | end |
|
296 | 297 | |
|
297 | 298 | def move_issues |
|
298 | 299 | @issues = @project.issues.find(params[:issue_ids]) if params[:issue_ids] |
|
299 | 300 | redirect_to :action => 'list_issues', :id => @project and return unless @issues |
|
300 | 301 | @projects = [] |
|
301 | 302 | # find projects to which the user is allowed to move the issue |
|
302 | 303 | @logged_in_user.memberships.each {|m| @projects << m.project if Permission.allowed_to_role("projects/move_issues", m.role_id)} |
|
303 | 304 | # issue can be moved to any tracker |
|
304 | 305 | @trackers = Tracker.find(:all) |
|
305 | 306 | if request.post? and params[:new_project_id] and params[:new_tracker_id] |
|
306 | 307 | new_project = Project.find(params[:new_project_id]) |
|
307 | 308 | new_tracker = Tracker.find(params[:new_tracker_id]) |
|
308 | 309 | @issues.each { |i| |
|
309 | 310 | # project dependent properties |
|
310 | 311 | unless i.project_id == new_project.id |
|
311 | 312 | i.category = nil |
|
312 | 313 | i.fixed_version = nil |
|
313 | 314 | end |
|
314 | 315 | # move the issue |
|
315 | 316 | i.project = new_project |
|
316 | 317 | i.tracker = new_tracker |
|
317 | 318 | i.save |
|
318 | 319 | } |
|
319 | 320 | flash[:notice] = l(:notice_successful_update) |
|
320 | 321 | redirect_to :action => 'list_issues', :id => @project |
|
321 | 322 | end |
|
322 | 323 | end |
|
323 | 324 | |
|
324 | 325 | def add_query |
|
325 | 326 | @query = Query.new(params[:query]) |
|
326 | 327 | @query.project = @project |
|
327 | 328 | @query.user = logged_in_user |
|
328 | 329 | |
|
329 | 330 | params[:fields].each do |field| |
|
330 | 331 | @query.add_filter(field, params[:operators][field], params[:values][field]) |
|
331 | 332 | end if params[:fields] |
|
332 | 333 | |
|
333 | 334 | if request.post? and @query.save |
|
334 | 335 | flash[:notice] = l(:notice_successful_create) |
|
335 | 336 | redirect_to :controller => 'reports', :action => 'issue_report', :id => @project |
|
336 | 337 | end |
|
337 | 338 | render :layout => false if request.xhr? |
|
338 | 339 | end |
|
339 | 340 | |
|
340 | 341 | # Add a news to @project |
|
341 | 342 | def add_news |
|
342 | 343 | @news = News.new(:project => @project) |
|
343 | 344 | if request.post? |
|
344 | 345 | @news.attributes = params[:news] |
|
345 | 346 | @news.author_id = self.logged_in_user.id if self.logged_in_user |
|
346 | 347 | if @news.save |
|
347 | 348 | flash[:notice] = l(:notice_successful_create) |
|
348 | 349 | redirect_to :action => 'list_news', :id => @project |
|
349 | 350 | end |
|
350 | 351 | end |
|
351 | 352 | end |
|
352 | 353 | |
|
353 | 354 | # Show news list of @project |
|
354 | 355 | def list_news |
|
355 | 356 | @news_pages, @news = paginate :news, :per_page => 10, :conditions => ["project_id=?", @project.id], :include => :author, :order => "news.created_on DESC" |
|
356 | 357 | render :action => "list_news", :layout => false if request.xhr? |
|
357 | 358 | end |
|
358 | 359 | |
|
359 | 360 | def add_file |
|
360 | 361 | if request.post? |
|
361 | 362 | @version = @project.versions.find_by_id(params[:version_id]) |
|
362 | 363 | # Save the attachments |
|
363 | 364 | params[:attachments].each { |a| |
|
364 | 365 | Attachment.create(:container => @version, :file => a, :author => logged_in_user) unless a.size == 0 |
|
365 | 366 | } if params[:attachments] and params[:attachments].is_a? Array |
|
366 | 367 | redirect_to :controller => 'projects', :action => 'list_files', :id => @project |
|
367 | 368 | end |
|
368 | 369 | @versions = @project.versions |
|
369 | 370 | end |
|
370 | 371 | |
|
371 | 372 | def list_files |
|
372 | 373 | @versions = @project.versions |
|
373 | 374 | end |
|
374 | 375 | |
|
375 | 376 | # Show changelog for @project |
|
376 | 377 | def changelog |
|
377 | 378 | @trackers = Tracker.find(:all, :conditions => ["is_in_chlog=?", true]) |
|
378 | 379 | if request.get? |
|
379 | 380 | @selected_tracker_ids = @trackers.collect {|t| t.id.to_s } |
|
380 | 381 | else |
|
381 | 382 | @selected_tracker_ids = params[:tracker_ids].collect { |id| id.to_i.to_s } if params[:tracker_ids] and params[:tracker_ids].is_a? Array |
|
382 | 383 | end |
|
383 | 384 | @selected_tracker_ids ||= [] |
|
384 | 385 | @fixed_issues = @project.issues.find(:all, |
|
385 | 386 | :include => [ :fixed_version, :status, :tracker ], |
|
386 | 387 | :conditions => [ "issue_statuses.is_closed=? and issues.tracker_id in (#{@selected_tracker_ids.join(',')}) and issues.fixed_version_id is not null", true], |
|
387 | 388 | :order => "versions.effective_date DESC, issues.id DESC" |
|
388 | 389 | ) unless @selected_tracker_ids.empty? |
|
389 | 390 | @fixed_issues ||= [] |
|
390 | 391 | end |
|
391 | 392 | |
|
392 | 393 | def activity |
|
393 | 394 | if params[:year] and params[:year].to_i > 1900 |
|
394 | 395 | @year = params[:year].to_i |
|
395 | 396 | if params[:month] and params[:month].to_i > 0 and params[:month].to_i < 13 |
|
396 | 397 | @month = params[:month].to_i |
|
397 | 398 | end |
|
398 | 399 | end |
|
399 | 400 | @year ||= Date.today.year |
|
400 | 401 | @month ||= Date.today.month |
|
401 | 402 | |
|
402 | 403 | @date_from = Date.civil(@year, @month, 1) |
|
403 | 404 | @date_to = (@date_from >> 1)-1 |
|
404 | 405 | |
|
405 | 406 | @events_by_day = {} |
|
406 | 407 | |
|
407 | 408 | unless params[:show_issues] == "0" |
|
408 | 409 | @project.issues.find(:all, :include => [:author, :status], :conditions => ["issues.created_on>=? and issues.created_on<=?", @date_from, @date_to] ).each { |i| |
|
409 | 410 | @events_by_day[i.created_on.to_date] ||= [] |
|
410 | 411 | @events_by_day[i.created_on.to_date] << i |
|
411 | 412 | } |
|
412 | 413 | @show_issues = 1 |
|
413 | 414 | end |
|
414 | 415 | |
|
415 | 416 | unless params[:show_news] == "0" |
|
416 | 417 | @project.news.find(:all, :conditions => ["news.created_on>=? and news.created_on<=?", @date_from, @date_to], :include => :author ).each { |i| |
|
417 | 418 | @events_by_day[i.created_on.to_date] ||= [] |
|
418 | 419 | @events_by_day[i.created_on.to_date] << i |
|
419 | 420 | } |
|
420 | 421 | @show_news = 1 |
|
421 | 422 | end |
|
422 | 423 | |
|
423 | 424 | unless params[:show_files] == "0" |
|
424 | 425 | Attachment.find(:all, :select => "attachments.*", :joins => "LEFT JOIN versions ON versions.id = attachments.container_id", :conditions => ["attachments.container_type='Version' and versions.project_id=? and attachments.created_on>=? and attachments.created_on<=?", @project.id, @date_from, @date_to], :include => :author ).each { |i| |
|
425 | 426 | @events_by_day[i.created_on.to_date] ||= [] |
|
426 | 427 | @events_by_day[i.created_on.to_date] << i |
|
427 | 428 | } |
|
428 | 429 | @show_files = 1 |
|
429 | 430 | end |
|
430 | 431 | |
|
431 | 432 | unless params[:show_documents] == "0" |
|
432 | 433 | @project.documents.find(:all, :conditions => ["documents.created_on>=? and documents.created_on<=?", @date_from, @date_to] ).each { |i| |
|
433 | 434 | @events_by_day[i.created_on.to_date] ||= [] |
|
434 | 435 | @events_by_day[i.created_on.to_date] << i |
|
435 | 436 | } |
|
436 | 437 | Attachment.find(:all, :select => "attachments.*", :joins => "LEFT JOIN documents ON documents.id = attachments.container_id", :conditions => ["attachments.container_type='Document' and documents.project_id=? and attachments.created_on>=? and attachments.created_on<=?", @project.id, @date_from, @date_to], :include => :author ).each { |i| |
|
437 | 438 | @events_by_day[i.created_on.to_date] ||= [] |
|
438 | 439 | @events_by_day[i.created_on.to_date] << i |
|
439 | 440 | } |
|
440 | 441 | @show_documents = 1 |
|
441 | 442 | end |
|
442 | 443 | |
|
443 | 444 | render :layout => false if request.xhr? |
|
444 | 445 | end |
|
445 | 446 | |
|
446 | 447 | def calendar |
|
447 | 448 | if params[:year] and params[:year].to_i > 1900 |
|
448 | 449 | @year = params[:year].to_i |
|
449 | 450 | if params[:month] and params[:month].to_i > 0 and params[:month].to_i < 13 |
|
450 | 451 | @month = params[:month].to_i |
|
451 | 452 | end |
|
452 | 453 | end |
|
453 | 454 | @year ||= Date.today.year |
|
454 | 455 | @month ||= Date.today.month |
|
455 | 456 | |
|
456 | 457 | @date_from = Date.civil(@year, @month, 1) |
|
457 | 458 | @date_to = (@date_from >> 1)-1 |
|
458 | 459 | # start on monday |
|
459 | 460 | @date_from = @date_from - (@date_from.cwday-1) |
|
460 | 461 | # finish on sunday |
|
461 | 462 | @date_to = @date_to + (7-@date_to.cwday) |
|
462 | 463 | |
|
463 | 464 | @issues = @project.issues.find(:all, :include => :tracker, :conditions => ["((start_date>=? and start_date<=?) or (due_date>=? and due_date<=?))", @date_from, @date_to, @date_from, @date_to]) |
|
464 | 465 | render :layout => false if request.xhr? |
|
465 | 466 | end |
|
466 | 467 | |
|
467 | 468 | def gantt |
|
468 | 469 | if params[:year] and params[:year].to_i >0 |
|
469 | 470 | @year_from = params[:year].to_i |
|
470 | 471 | if params[:month] and params[:month].to_i >=1 and params[:month].to_i <= 12 |
|
471 | 472 | @month_from = params[:month].to_i |
|
472 | 473 | else |
|
473 | 474 | @month_from = 1 |
|
474 | 475 | end |
|
475 | 476 | else |
|
476 | 477 | @month_from ||= (Date.today << 1).month |
|
477 | 478 | @year_from ||= (Date.today << 1).year |
|
478 | 479 | end |
|
479 | 480 | |
|
480 | 481 | @zoom = (params[:zoom].to_i > 0 and params[:zoom].to_i < 5) ? params[:zoom].to_i : 2 |
|
481 | 482 | @months = (params[:months].to_i > 0 and params[:months].to_i < 25) ? params[:months].to_i : 6 |
|
482 | 483 | |
|
483 | 484 | @date_from = Date.civil(@year_from, @month_from, 1) |
|
484 | 485 | @date_to = (@date_from >> @months) - 1 |
|
485 | 486 | @issues = @project.issues.find(:all, :order => "start_date, due_date", :conditions => ["(((start_date>=? and start_date<=?) or (due_date>=? and due_date<=?) or (start_date<? and due_date>?)) and start_date is not null and due_date is not null)", @date_from, @date_to, @date_from, @date_to, @date_from, @date_to]) |
|
486 | 487 | |
|
487 | 488 | if params[:output]=='pdf' |
|
488 | 489 | @options_for_rfpdf ||= {} |
|
489 | 490 | @options_for_rfpdf[:file_name] = "gantt.pdf" |
|
490 | 491 | render :template => "projects/gantt.rfpdf", :layout => false |
|
491 | 492 | else |
|
492 | 493 | render :template => "projects/gantt.rhtml" |
|
493 | 494 | end |
|
494 | 495 | end |
|
495 | 496 | |
|
496 | 497 | private |
|
497 | 498 | # Find project of id params[:id] |
|
498 | 499 | # if not found, redirect to project list |
|
499 | 500 | # Used as a before_filter |
|
500 | 501 | def find_project |
|
501 | 502 | @project = Project.find(params[:id]) |
|
502 | 503 | @html_title = @project.name |
|
503 | 504 | rescue ActiveRecord::RecordNotFound |
|
504 | 505 | render_404 |
|
505 | 506 | end |
|
506 | 507 | |
|
507 | 508 | # Retrieve query from session or build a new query |
|
508 | 509 | def retrieve_query |
|
509 | 510 | if params[:query_id] |
|
510 | 511 | @query = @project.queries.find(params[:query_id]) |
|
511 | 512 | else |
|
512 | 513 | if params[:set_filter] or !session[:query] or session[:query].project_id != @project.id |
|
513 | 514 | # Give it a name, required to be valid |
|
514 | 515 | @query = Query.new(:name => "_") |
|
515 | 516 | @query.project = @project |
|
516 | 517 | if params[:fields] and params[:fields].is_a? Array |
|
517 | 518 | params[:fields].each do |field| |
|
518 | 519 | @query.add_filter(field, params[:operators][field], params[:values][field]) |
|
519 | 520 | end |
|
520 | 521 | else |
|
521 | 522 | @query.available_filters.keys.each do |field| |
|
522 | 523 | @query.add_short_filter(field, params[field]) if params[field] |
|
523 | 524 | end |
|
524 | 525 | end |
|
525 | 526 | session[:query] = @query |
|
526 | 527 | else |
|
527 | 528 | @query = session[:query] |
|
528 | 529 | end |
|
529 | 530 | end |
|
530 | 531 | end |
|
531 | 532 | end |
@@ -1,81 +1,85 | |||
|
1 | 1 | <% if @query.new_record? %> |
|
2 | <div class="contextual"> | |
|
3 | <%= render :partial => 'issues/add_shortcut', :locals => {:trackers => @trackers } %> | |
|
4 | </div> | |
|
2 | 5 | <h2><%=l(:label_issue_plural)%></h2> |
|
3 | 6 | |
|
4 | 7 | <%= start_form_tag({:action => 'list_issues'}, :id => 'query_form') %> |
|
5 | 8 | <%= render :partial => 'queries/filters', :locals => {:query => @query} %> |
|
6 | 9 | <%= end_form_tag %> |
|
7 | 10 | <div class="contextual"> |
|
8 | 11 | <%= link_to_remote l(:button_apply), |
|
9 | 12 | { :url => { :controller => 'projects', :action => 'list_issues', :id => @project, :set_filter => 1 }, |
|
10 | 13 | :update => "content", |
|
11 | 14 | :with => "Form.serialize('query_form')" |
|
12 | 15 | }, :class => 'pic picCheck' %> |
|
13 | 16 | |
|
14 | 17 | <%= link_to l(:button_clear), {:controller => 'projects', :action => 'list_issues', :id => @project, :set_filter => 1}, :class => 'pic picDelete' %> |
|
15 | 18 | <% if authorize_for('projects', 'add_query') %> |
|
16 | 19 | |
|
17 | 20 | <%= link_to_remote l(:button_save), |
|
18 | 21 | { :url => { :controller => 'projects', :action => "add_query", :id => @project }, |
|
19 | 22 | :method => 'get', |
|
20 | 23 | :update => "content", |
|
21 | 24 | :with => "Form.serialize('query_form')" |
|
22 | 25 | }, :class => 'pic picEdit' %> |
|
23 | 26 | <% end %> |
|
24 | 27 | </div> |
|
25 | 28 | <br /> |
|
26 | 29 | <% else %> |
|
27 | <% if authorize_for('projects', 'add_query') %> | |
|
28 | 30 | <div class="contextual"> |
|
29 | <%= link_to l(:button_edit), {:controller => 'queries', :action => 'edit', :id => @query}, :class => 'pic picEdit' %> | |
|
30 | <%= link_to l(:button_delete), {:controller => 'queries', :action => 'destroy', :id => @query}, :confirm => l(:text_are_you_sure), :post => true, :class => 'pic picDelete' %> | |
|
31 | <%= render :partial => 'issues/add_shortcut', :locals => {:trackers => @trackers } %> | |
|
32 | <% if authorize_for('projects', 'add_query') %> | |
|
33 | <%= link_to l(:button_edit), {:controller => 'queries', :action => 'edit', :id => @query}, :class => 'pic picEdit' %> | |
|
34 | <%= link_to l(:button_delete), {:controller => 'queries', :action => 'destroy', :id => @query}, :confirm => l(:text_are_you_sure), :post => true, :class => 'pic picDelete' %> | |
|
35 | <% end %> | |
|
31 | 36 | </div> |
|
32 | <% end %> | |
|
33 | 37 | <h2><%= @query.name %></h2> |
|
34 | 38 | <% end %> |
|
35 | 39 | <%= error_messages_for 'query' %> |
|
36 | 40 | <% if @query.valid? %> |
|
37 | 41 | <% if @issues.empty? %> |
|
38 | 42 | <p><i><%= l(:label_no_data) %></i></p> |
|
39 | 43 | <% else %> |
|
40 | 44 | |
|
41 | 45 | <%= start_form_tag({:controller => 'projects', :action => 'move_issues', :id => @project}, :id => 'issues_form' ) %> |
|
42 | 46 | <table class="list"> |
|
43 | 47 | <thead><tr> |
|
44 | 48 | <th></th> |
|
45 | 49 | <%= sort_header_tag('issues.id', :caption => '#') %> |
|
46 | 50 | <%= sort_header_tag('issues.tracker_id', :caption => l(:field_tracker)) %> |
|
47 | 51 | <%= sort_header_tag('issue_statuses.name', :caption => l(:field_status)) %> |
|
48 | 52 | <th><%=l(:field_subject)%></th> |
|
49 | 53 | <%= sort_header_tag('users.lastname', :caption => l(:field_author)) %> |
|
50 | 54 | <%= sort_header_tag('issues.created_on', :caption => l(:field_created_on)) %> |
|
51 | 55 | <%= sort_header_tag('issues.updated_on', :caption => l(:field_updated_on)) %> |
|
52 | 56 | </tr></thead> |
|
53 | 57 | <tbody> |
|
54 | 58 | <% for issue in @issues %> |
|
55 | 59 | <tr class="<%= cycle("odd", "even") %>"> |
|
56 | 60 | <th width="15"><%= check_box_tag "issue_ids[]", issue.id %></th> |
|
57 | 61 | <td align="center"><%= link_to issue.id, :controller => 'issues', :action => 'show', :id => issue %></td> |
|
58 | 62 | <td align="center"><%= issue.tracker.name %></td> |
|
59 | 63 | <td><div class="square" style="background:#<%= issue.status.html_color %>;"></div> <%= issue.status.name %></td> |
|
60 | 64 | <td><%= link_to h(issue.subject), :controller => 'issues', :action => 'show', :id => issue %></td> |
|
61 | 65 | <td align="center"><%= issue.author.display_name %></td> |
|
62 | 66 | <td align="center"><%= format_time(issue.created_on) %></td> |
|
63 | 67 | <td align="center"><%= format_time(issue.updated_on) %></td> |
|
64 | 68 | </tr> |
|
65 | 69 | <% end %> |
|
66 | 70 | </tbody> |
|
67 | 71 | </table> |
|
68 | 72 | <div class="contextual"> |
|
69 | 73 | <%= l(:label_export_to) %> |
|
70 | 74 | <%= link_to 'CSV', {:action => 'export_issues_csv', :id => @project}, :class => 'icon file' %>, |
|
71 | 75 | <%= link_to 'PDF', {:action => 'export_issues_pdf', :id => @project}, :class => 'pic picPdf' %> |
|
72 | 76 | </div> |
|
73 | 77 | |
|
74 | 78 | <%= submit_tag l(:button_move), :class => "button-small" %> |
|
75 | 79 | <%= end_form_tag %> |
|
76 | 80 | |
|
77 | 81 | <%= pagination_links_full @issue_pages %> |
|
78 | 82 | [ <%= @issue_pages.current.first_item %> - <%= @issue_pages.current.last_item %> / <%= @issue_count %> ] |
|
79 | 83 | |
|
80 | 84 | <% end %> |
|
81 | 85 | <% end %> No newline at end of file |
@@ -1,67 +1,62 | |||
|
1 | 1 | <h2><%=l(:label_overview)%></h2> |
|
2 | 2 | |
|
3 | 3 | <div class="splitcontentleft"> |
|
4 | 4 | <%= simple_format(auto_link(h(@project.description))) %> |
|
5 | 5 | <ul> |
|
6 | 6 | <% unless @project.homepage.empty? %><li><%=l(:field_homepage)%>: <%= auto_link @project.homepage %></li><% end %> |
|
7 | 7 | <li><%=l(:field_created_on)%>: <%= format_date(@project.created_on) %></li> |
|
8 | 8 | <% for custom_value in @custom_values %> |
|
9 | 9 | <% if !custom_value.value.empty? %> |
|
10 | 10 | <li><%= custom_value.custom_field.name%>: <%=h show_value(custom_value) %></li> |
|
11 | 11 | <% end %> |
|
12 | 12 | <% end %> |
|
13 | 13 | </ul> |
|
14 | 14 | |
|
15 | 15 | <div class="box"> |
|
16 | <div class="contextual"> | |
|
17 | <%= render :partial => 'issues/add_shortcut', :locals => {:trackers => @trackers } %> | |
|
18 | </div> | |
|
16 | 19 | <h3><%= image_tag "tracker" %> <%=l(:label_tracker_plural)%></h3> |
|
17 | 20 | <ul> |
|
18 | 21 | <% for tracker in @trackers %> |
|
19 | 22 | <li><%= link_to tracker.name, :controller => 'projects', :action => 'list_issues', :id => @project, |
|
20 | 23 | :set_filter => 1, |
|
21 | 24 | "tracker_id" => tracker.id %>: |
|
22 | 25 | <%= issue_count = Issue.count(:conditions => ["project_id=? and tracker_id=? and issue_statuses.is_closed=?", @project.id, tracker.id, false], :include => :status) %> |
|
23 | 26 | <%= lwr(:label_open_issues, issue_count) %> |
|
24 | 27 | </li> |
|
25 | 28 | <% end %> |
|
26 | </ul> | |
|
27 | <% if authorize_for 'projects', 'add_issue' %> | |
|
28 | » <%=l(:label_issue_new)%>: | |
|
29 | <ul> | |
|
30 | <% @trackers.each do |tracker| %> | |
|
31 | <li><%= link_to tracker.name, :controller => 'projects', :action => 'add_issue', :id => @project, :tracker_id => tracker %></li> | |
|
32 | <% end %> | |
|
33 | </ul> | |
|
34 | <% end %> | |
|
29 | </ul> | |
|
35 | 30 | <center><small><%= link_to l(:label_issue_view_all), :controller => 'projects', :action => 'list_issues', :id => @project, :set_filter => 1 %></small></center> |
|
36 | 31 | </div> |
|
37 | 32 | </div> |
|
38 | 33 | |
|
39 | 34 | <div class="splitcontentright"> |
|
40 | 35 | <div class="box"> |
|
41 | 36 | <h3><%= image_tag "users" %> <%=l(:label_member_plural)%></h3> |
|
42 | 37 | <% for member in @members %> |
|
43 | 38 | <%= link_to_user member.user %> (<%= member.role.name %>)<br /> |
|
44 | 39 | <% end %> |
|
45 | 40 | </div> |
|
46 | 41 | |
|
47 | 42 | <% if @subprojects %> |
|
48 | 43 | <div class="box"> |
|
49 | 44 | <h3><%= image_tag "projects" %> <%=l(:label_subproject_plural)%></h3> |
|
50 | 45 | <% for subproject in @subprojects %> |
|
51 | 46 | <%= link_to subproject.name, :action => 'show', :id => subproject %><br /> |
|
52 | 47 | <% end %> |
|
53 | 48 | </div> |
|
54 | 49 | <% end %> |
|
55 | 50 | |
|
56 | 51 | <div class="box"> |
|
57 | 52 | <h3><%=l(:label_news_latest)%></h3> |
|
58 | 53 | <%= render :partial => 'news/news', :collection => @news %> |
|
59 | 54 | <center><small><%= link_to l(:label_news_view_all), :controller => 'projects', :action => 'list_news', :id => @project %></small></center> |
|
60 | 55 | </div> |
|
61 | 56 | </div> |
|
62 | 57 | |
|
63 | 58 | |
|
64 | 59 | |
|
65 | 60 | |
|
66 | 61 | |
|
67 | 62 |
General Comments 0
You need to be logged in to leave comments.
Login now