##// END OF EJS Templates
Merged r2979 and r2980 from trunk....
Jean-Philippe Lang -
r2884:c12b96a89fca
parent child
Show More
@@ -1,491 +1,495
1 1 # Redmine - project management software
2 2 # Copyright (C) 2006-2008 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 IssuesController < ApplicationController
19 19 menu_item :new_issue, :only => :new
20 20
21 21 before_filter :find_issue, :only => [:show, :edit, :reply]
22 22 before_filter :find_issues, :only => [:bulk_edit, :move, :destroy]
23 23 before_filter :find_project, :only => [:new, :update_form, :preview]
24 24 before_filter :authorize, :except => [:index, :changes, :gantt, :calendar, :preview, :update_form, :context_menu]
25 25 before_filter :find_optional_project, :only => [:index, :changes, :gantt, :calendar]
26 26 accept_key_auth :index, :show, :changes
27 27
28 28 helper :journals
29 29 helper :projects
30 30 include ProjectsHelper
31 31 helper :custom_fields
32 32 include CustomFieldsHelper
33 33 helper :issue_relations
34 34 include IssueRelationsHelper
35 35 helper :watchers
36 36 include WatchersHelper
37 37 helper :attachments
38 38 include AttachmentsHelper
39 39 helper :queries
40 40 helper :sort
41 41 include SortHelper
42 42 include IssuesHelper
43 43 helper :timelog
44 44 include Redmine::Export::PDF
45 45
46 verify :method => :post,
47 :only => :destroy,
48 :render => { :nothing => true, :status => :method_not_allowed }
49
46 50 def index
47 51 retrieve_query
48 52 sort_init 'id', 'desc'
49 53 sort_update({'id' => "#{Issue.table_name}.id"}.merge(@query.columns.inject({}) {|h, c| h[c.name.to_s] = c.sortable; h}))
50 54
51 55 if @query.valid?
52 56 limit = per_page_option
53 57 respond_to do |format|
54 58 format.html { }
55 59 format.atom { }
56 60 format.csv { limit = Setting.issues_export_limit.to_i }
57 61 format.pdf { limit = Setting.issues_export_limit.to_i }
58 62 end
59 63 @issue_count = Issue.count(:include => [:status, :project], :conditions => @query.statement)
60 64 @issue_pages = Paginator.new self, @issue_count, limit, params['page']
61 65 @issues = Issue.find :all, :order => sort_clause,
62 66 :include => [ :assigned_to, :status, :tracker, :project, :priority, :category, :fixed_version ],
63 67 :conditions => @query.statement,
64 68 :limit => limit,
65 69 :offset => @issue_pages.current.offset
66 70 respond_to do |format|
67 71 format.html { render :template => 'issues/index.rhtml', :layout => !request.xhr? }
68 72 format.atom { render_feed(@issues, :title => "#{@project || Setting.app_title}: #{l(:label_issue_plural)}") }
69 73 format.csv { send_data(issues_to_csv(@issues, @project).read, :type => 'text/csv; header=present', :filename => 'export.csv') }
70 74 format.pdf { send_data(issues_to_pdf(@issues, @project), :type => 'application/pdf', :filename => 'export.pdf') }
71 75 end
72 76 else
73 77 # Send html if the query is not valid
74 78 render(:template => 'issues/index.rhtml', :layout => !request.xhr?)
75 79 end
76 80 rescue ActiveRecord::RecordNotFound
77 81 render_404
78 82 end
79 83
80 84 def changes
81 85 retrieve_query
82 86 sort_init 'id', 'desc'
83 87 sort_update({'id' => "#{Issue.table_name}.id"}.merge(@query.columns.inject({}) {|h, c| h[c.name.to_s] = c.sortable; h}))
84 88
85 89 if @query.valid?
86 90 @journals = Journal.find :all, :include => [ :details, :user, {:issue => [:project, :author, :tracker, :status]} ],
87 91 :conditions => @query.statement,
88 92 :limit => 25,
89 93 :order => "#{Journal.table_name}.created_on DESC"
90 94 end
91 95 @title = (@project ? @project.name : Setting.app_title) + ": " + (@query.new_record? ? l(:label_changes_details) : @query.name)
92 96 render :layout => false, :content_type => 'application/atom+xml'
93 97 rescue ActiveRecord::RecordNotFound
94 98 render_404
95 99 end
96 100
97 101 def show
98 102 @journals = @issue.journals.find(:all, :include => [:user, :details], :order => "#{Journal.table_name}.created_on ASC")
99 103 @journals.each_with_index {|j,i| j.indice = i+1}
100 104 @journals.reverse! if User.current.wants_comments_in_reverse_order?
101 105 @allowed_statuses = @issue.new_statuses_allowed_to(User.current)
102 106 @edit_allowed = User.current.allowed_to?(:edit_issues, @project)
103 107 @priorities = Enumeration::get_values('IPRI')
104 108 @time_entry = TimeEntry.new
105 109 respond_to do |format|
106 110 format.html { render :template => 'issues/show.rhtml' }
107 111 format.atom { render :action => 'changes', :layout => false, :content_type => 'application/atom+xml' }
108 112 format.pdf { send_data(issue_to_pdf(@issue), :type => 'application/pdf', :filename => "#{@project.identifier}-#{@issue.id}.pdf") }
109 113 end
110 114 end
111 115
112 116 # Add a new issue
113 117 # The new issue will be created from an existing one if copy_from parameter is given
114 118 def new
115 119 @issue = Issue.new
116 120 @issue.copy_from(params[:copy_from]) if params[:copy_from]
117 121 @issue.project = @project
118 122 # Tracker must be set before custom field values
119 123 @issue.tracker ||= @project.trackers.find((params[:issue] && params[:issue][:tracker_id]) || params[:tracker_id] || :first)
120 124 if @issue.tracker.nil?
121 125 flash.now[:error] = 'No tracker is associated to this project. Please check the Project settings.'
122 126 render :nothing => true, :layout => true
123 127 return
124 128 end
125 129 if params[:issue].is_a?(Hash)
126 130 @issue.attributes = params[:issue]
127 131 @issue.watcher_user_ids = params[:issue]['watcher_user_ids'] if User.current.allowed_to?(:add_issue_watchers, @project)
128 132 end
129 133 @issue.author = User.current
130 134
131 135 default_status = IssueStatus.default
132 136 unless default_status
133 137 flash.now[:error] = 'No default issue status is defined. Please check your configuration (Go to "Administration -> Issue statuses").'
134 138 render :nothing => true, :layout => true
135 139 return
136 140 end
137 141 @issue.status = default_status
138 142 @allowed_statuses = ([default_status] + default_status.find_new_statuses_allowed_to(User.current.role_for_project(@project), @issue.tracker)).uniq
139 143
140 144 if request.get? || request.xhr?
141 145 @issue.start_date ||= Date.today
142 146 else
143 147 requested_status = IssueStatus.find_by_id(params[:issue][:status_id])
144 148 # Check that the user is allowed to apply the requested status
145 149 @issue.status = (@allowed_statuses.include? requested_status) ? requested_status : default_status
146 150 if @issue.save
147 151 attach_files(@issue, params[:attachments])
148 152 flash[:notice] = l(:notice_successful_create)
149 153 Mailer.deliver_issue_add(@issue) if Setting.notified_events.include?('issue_added')
150 154 call_hook(:controller_issues_new_after_save, { :params => params, :issue => @issue})
151 155 redirect_to(params[:continue] ? { :action => 'new', :tracker_id => @issue.tracker } :
152 156 { :action => 'show', :id => @issue })
153 157 return
154 158 end
155 159 end
156 160 @priorities = Enumeration::get_values('IPRI')
157 161 render :layout => !request.xhr?
158 162 end
159 163
160 164 # Attributes that can be updated on workflow transition (without :edit permission)
161 165 # TODO: make it configurable (at least per role)
162 166 UPDATABLE_ATTRS_ON_TRANSITION = %w(status_id assigned_to_id fixed_version_id done_ratio) unless const_defined?(:UPDATABLE_ATTRS_ON_TRANSITION)
163 167
164 168 def edit
165 169 @allowed_statuses = @issue.new_statuses_allowed_to(User.current)
166 170 @priorities = Enumeration::get_values('IPRI')
167 171 @edit_allowed = User.current.allowed_to?(:edit_issues, @project)
168 172 @time_entry = TimeEntry.new
169 173
170 174 @notes = params[:notes]
171 175 journal = @issue.init_journal(User.current, @notes)
172 176 # User can change issue attributes only if he has :edit permission or if a workflow transition is allowed
173 177 if (@edit_allowed || !@allowed_statuses.empty?) && params[:issue]
174 178 attrs = params[:issue].dup
175 179 attrs.delete_if {|k,v| !UPDATABLE_ATTRS_ON_TRANSITION.include?(k) } unless @edit_allowed
176 180 attrs.delete(:status_id) unless @allowed_statuses.detect {|s| s.id.to_s == attrs[:status_id].to_s}
177 181 @issue.attributes = attrs
178 182 end
179 183
180 184 if request.post?
181 185 @time_entry = TimeEntry.new(:project => @project, :issue => @issue, :user => User.current, :spent_on => Date.today)
182 186 @time_entry.attributes = params[:time_entry]
183 187 attachments = attach_files(@issue, params[:attachments])
184 188 attachments.each {|a| journal.details << JournalDetail.new(:property => 'attachment', :prop_key => a.id, :value => a.filename)}
185 189
186 190 call_hook(:controller_issues_edit_before_save, { :params => params, :issue => @issue, :time_entry => @time_entry, :journal => journal})
187 191
188 192 if (@time_entry.hours.nil? || @time_entry.valid?) && @issue.save
189 193 # Log spend time
190 194 if User.current.allowed_to?(:log_time, @project)
191 195 @time_entry.save
192 196 end
193 197 if !journal.new_record?
194 198 # Only send notification if something was actually changed
195 199 flash[:notice] = l(:notice_successful_update)
196 200 Mailer.deliver_issue_edit(journal) if Setting.notified_events.include?('issue_updated')
197 201 end
198 202 call_hook(:controller_issues_edit_after_save, { :params => params, :issue => @issue, :time_entry => @time_entry, :journal => journal})
199 203 redirect_to(params[:back_to] || {:action => 'show', :id => @issue})
200 204 end
201 205 end
202 206 rescue ActiveRecord::StaleObjectError
203 207 # Optimistic locking exception
204 208 flash.now[:error] = l(:notice_locking_conflict)
205 209 end
206 210
207 211 def reply
208 212 journal = Journal.find(params[:journal_id]) if params[:journal_id]
209 213 if journal
210 214 user = journal.user
211 215 text = journal.notes
212 216 else
213 217 user = @issue.author
214 218 text = @issue.description
215 219 end
216 220 content = "#{ll(Setting.default_language, :text_user_wrote, user)}\\n> "
217 221 content << text.to_s.strip.gsub(%r{<pre>((.|\s)*?)</pre>}m, '[...]').gsub('"', '\"').gsub(/(\r?\n|\r\n?)/, "\\n> ") + "\\n\\n"
218 222 render(:update) { |page|
219 223 page.<< "$('notes').value = \"#{content}\";"
220 224 page.show 'update'
221 225 page << "Form.Element.focus('notes');"
222 226 page << "Element.scrollTo('update');"
223 227 page << "$('notes').scrollTop = $('notes').scrollHeight - $('notes').clientHeight;"
224 228 }
225 229 end
226 230
227 231 # Bulk edit a set of issues
228 232 def bulk_edit
229 233 if request.post?
230 234 status = params[:status_id].blank? ? nil : IssueStatus.find_by_id(params[:status_id])
231 235 priority = params[:priority_id].blank? ? nil : Enumeration.find_by_id(params[:priority_id])
232 236 assigned_to = (params[:assigned_to_id].blank? || params[:assigned_to_id] == 'none') ? nil : User.find_by_id(params[:assigned_to_id])
233 237 category = (params[:category_id].blank? || params[:category_id] == 'none') ? nil : @project.issue_categories.find_by_id(params[:category_id])
234 238 fixed_version = (params[:fixed_version_id].blank? || params[:fixed_version_id] == 'none') ? nil : @project.versions.find_by_id(params[:fixed_version_id])
235 239
236 240 unsaved_issue_ids = []
237 241 @issues.each do |issue|
238 242 journal = issue.init_journal(User.current, params[:notes])
239 243 issue.priority = priority if priority
240 244 issue.assigned_to = assigned_to if assigned_to || params[:assigned_to_id] == 'none'
241 245 issue.category = category if category || params[:category_id] == 'none'
242 246 issue.fixed_version = fixed_version if fixed_version || params[:fixed_version_id] == 'none'
243 247 issue.start_date = params[:start_date] unless params[:start_date].blank?
244 248 issue.due_date = params[:due_date] unless params[:due_date].blank?
245 249 issue.done_ratio = params[:done_ratio] unless params[:done_ratio].blank?
246 250 call_hook(:controller_issues_bulk_edit_before_save, { :params => params, :issue => issue })
247 251 # Don't save any change to the issue if the user is not authorized to apply the requested status
248 252 if (status.nil? || (issue.status.new_status_allowed_to?(status, current_role, issue.tracker) && issue.status = status)) && issue.save
249 253 # Send notification for each issue (if changed)
250 254 Mailer.deliver_issue_edit(journal) if journal.details.any? && Setting.notified_events.include?('issue_updated')
251 255 else
252 256 # Keep unsaved issue ids to display them in flash error
253 257 unsaved_issue_ids << issue.id
254 258 end
255 259 end
256 260 if unsaved_issue_ids.empty?
257 261 flash[:notice] = l(:notice_successful_update) unless @issues.empty?
258 262 else
259 263 flash[:error] = l(:notice_failed_to_save_issues, unsaved_issue_ids.size, @issues.size, '#' + unsaved_issue_ids.join(', #'))
260 264 end
261 265 redirect_to(params[:back_to] || {:controller => 'issues', :action => 'index', :project_id => @project})
262 266 return
263 267 end
264 268 # Find potential statuses the user could be allowed to switch issues to
265 269 @available_statuses = Workflow.find(:all, :include => :new_status,
266 270 :conditions => {:role_id => current_role.id}).collect(&:new_status).compact.uniq.sort
267 271 end
268 272
269 273 def move
270 274 @allowed_projects = []
271 275 # find projects to which the user is allowed to move the issue
272 276 if User.current.admin?
273 277 # admin is allowed to move issues to any active (visible) project
274 278 @allowed_projects = Project.find(:all, :conditions => Project.visible_by(User.current), :order => 'name')
275 279 else
276 280 User.current.memberships.each {|m| @allowed_projects << m.project if m.role.allowed_to?(:move_issues)}
277 281 end
278 282 @target_project = @allowed_projects.detect {|p| p.id.to_s == params[:new_project_id]} if params[:new_project_id]
279 283 @target_project ||= @project
280 284 @trackers = @target_project.trackers
281 285 if request.post?
282 286 new_tracker = params[:new_tracker_id].blank? ? nil : @target_project.trackers.find_by_id(params[:new_tracker_id])
283 287 unsaved_issue_ids = []
284 288 @issues.each do |issue|
285 289 issue.init_journal(User.current)
286 290 unsaved_issue_ids << issue.id unless issue.move_to(@target_project, new_tracker)
287 291 end
288 292 if unsaved_issue_ids.empty?
289 293 flash[:notice] = l(:notice_successful_update) unless @issues.empty?
290 294 else
291 295 flash[:error] = l(:notice_failed_to_save_issues, unsaved_issue_ids.size, @issues.size, '#' + unsaved_issue_ids.join(', #'))
292 296 end
293 297 redirect_to :controller => 'issues', :action => 'index', :project_id => @project
294 298 return
295 299 end
296 300 render :layout => false if request.xhr?
297 301 end
298 302
299 303 def destroy
300 304 @hours = TimeEntry.sum(:hours, :conditions => ['issue_id IN (?)', @issues]).to_f
301 305 if @hours > 0
302 306 case params[:todo]
303 307 when 'destroy'
304 308 # nothing to do
305 309 when 'nullify'
306 310 TimeEntry.update_all('issue_id = NULL', ['issue_id IN (?)', @issues])
307 311 when 'reassign'
308 312 reassign_to = @project.issues.find_by_id(params[:reassign_to_id])
309 313 if reassign_to.nil?
310 314 flash.now[:error] = l(:error_issue_not_found_in_project)
311 315 return
312 316 else
313 317 TimeEntry.update_all("issue_id = #{reassign_to.id}", ['issue_id IN (?)', @issues])
314 318 end
315 319 else
316 320 # display the destroy form
317 321 return
318 322 end
319 323 end
320 324 @issues.each(&:destroy)
321 325 redirect_to :action => 'index', :project_id => @project
322 326 end
323 327
324 328 def gantt
325 329 @gantt = Redmine::Helpers::Gantt.new(params)
326 330 retrieve_query
327 331 if @query.valid?
328 332 events = []
329 333 # Issues that have start and due dates
330 334 events += Issue.find(:all,
331 335 :order => "start_date, due_date",
332 336 :include => [:tracker, :status, :assigned_to, :priority, :project],
333 337 :conditions => ["(#{@query.statement}) AND (((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)", @gantt.date_from, @gantt.date_to, @gantt.date_from, @gantt.date_to, @gantt.date_from, @gantt.date_to]
334 338 )
335 339 # Issues that don't have a due date but that are assigned to a version with a date
336 340 events += Issue.find(:all,
337 341 :order => "start_date, effective_date",
338 342 :include => [:tracker, :status, :assigned_to, :priority, :project, :fixed_version],
339 343 :conditions => ["(#{@query.statement}) AND (((start_date>=? and start_date<=?) or (effective_date>=? and effective_date<=?) or (start_date<? and effective_date>?)) and start_date is not null and due_date is null and effective_date is not null)", @gantt.date_from, @gantt.date_to, @gantt.date_from, @gantt.date_to, @gantt.date_from, @gantt.date_to]
340 344 )
341 345 # Versions
342 346 events += Version.find(:all, :include => :project,
343 347 :conditions => ["(#{@query.project_statement}) AND effective_date BETWEEN ? AND ?", @gantt.date_from, @gantt.date_to])
344 348
345 349 @gantt.events = events
346 350 end
347 351
348 352 basename = (@project ? "#{@project.identifier}-" : '') + 'gantt'
349 353
350 354 respond_to do |format|
351 355 format.html { render :template => "issues/gantt.rhtml", :layout => !request.xhr? }
352 356 format.png { send_data(@gantt.to_image, :disposition => 'inline', :type => 'image/png', :filename => "#{basename}.png") } if @gantt.respond_to?('to_image')
353 357 format.pdf { send_data(gantt_to_pdf(@gantt, @project), :type => 'application/pdf', :filename => "#{basename}.pdf") }
354 358 end
355 359 end
356 360
357 361 def calendar
358 362 if params[:year] and params[:year].to_i > 1900
359 363 @year = params[:year].to_i
360 364 if params[:month] and params[:month].to_i > 0 and params[:month].to_i < 13
361 365 @month = params[:month].to_i
362 366 end
363 367 end
364 368 @year ||= Date.today.year
365 369 @month ||= Date.today.month
366 370
367 371 @calendar = Redmine::Helpers::Calendar.new(Date.civil(@year, @month, 1), current_language, :month)
368 372 retrieve_query
369 373 if @query.valid?
370 374 events = []
371 375 events += Issue.find(:all,
372 376 :include => [:tracker, :status, :assigned_to, :priority, :project],
373 377 :conditions => ["(#{@query.statement}) AND ((start_date BETWEEN ? AND ?) OR (due_date BETWEEN ? AND ?))", @calendar.startdt, @calendar.enddt, @calendar.startdt, @calendar.enddt]
374 378 )
375 379 events += Version.find(:all, :include => :project,
376 380 :conditions => ["(#{@query.project_statement}) AND effective_date BETWEEN ? AND ?", @calendar.startdt, @calendar.enddt])
377 381
378 382 @calendar.events = events
379 383 end
380 384
381 385 render :layout => false if request.xhr?
382 386 end
383 387
384 388 def context_menu
385 389 @issues = Issue.find_all_by_id(params[:ids], :include => :project)
386 390 if (@issues.size == 1)
387 391 @issue = @issues.first
388 392 @allowed_statuses = @issue.new_statuses_allowed_to(User.current)
389 393 end
390 394 projects = @issues.collect(&:project).compact.uniq
391 395 @project = projects.first if projects.size == 1
392 396
393 397 @can = {:edit => (@project && User.current.allowed_to?(:edit_issues, @project)),
394 398 :log_time => (@project && User.current.allowed_to?(:log_time, @project)),
395 399 :update => (@project && (User.current.allowed_to?(:edit_issues, @project) || (User.current.allowed_to?(:change_status, @project) && @allowed_statuses && !@allowed_statuses.empty?))),
396 400 :move => (@project && User.current.allowed_to?(:move_issues, @project)),
397 401 :copy => (@issue && @project.trackers.include?(@issue.tracker) && User.current.allowed_to?(:add_issues, @project)),
398 402 :delete => (@project && User.current.allowed_to?(:delete_issues, @project))
399 403 }
400 404 if @project
401 405 @assignables = @project.assignable_users
402 406 @assignables << @issue.assigned_to if @issue && @issue.assigned_to && !@assignables.include?(@issue.assigned_to)
403 407 end
404 408
405 409 @priorities = Enumeration.get_values('IPRI').reverse
406 410 @statuses = IssueStatus.find(:all, :order => 'position')
407 411 @back = request.env['HTTP_REFERER']
408 412
409 413 render :layout => false
410 414 end
411 415
412 416 def update_form
413 417 @issue = Issue.new(params[:issue])
414 418 render :action => :new, :layout => false
415 419 end
416 420
417 421 def preview
418 422 @issue = @project.issues.find_by_id(params[:id]) unless params[:id].blank?
419 423 @attachements = @issue.attachments if @issue
420 424 @text = params[:notes] || (params[:issue] ? params[:issue][:description] : nil)
421 425 render :partial => 'common/preview'
422 426 end
423 427
424 428 private
425 429 def find_issue
426 430 @issue = Issue.find(params[:id], :include => [:project, :tracker, :status, :author, :priority, :category])
427 431 @project = @issue.project
428 432 rescue ActiveRecord::RecordNotFound
429 433 render_404
430 434 end
431 435
432 436 # Filter for bulk operations
433 437 def find_issues
434 438 @issues = Issue.find_all_by_id(params[:id] || params[:ids])
435 439 raise ActiveRecord::RecordNotFound if @issues.empty?
436 440 projects = @issues.collect(&:project).compact.uniq
437 441 if projects.size == 1
438 442 @project = projects.first
439 443 else
440 444 # TODO: let users bulk edit/move/destroy issues from different projects
441 445 render_error 'Can not bulk edit/move/destroy issues from different projects' and return false
442 446 end
443 447 rescue ActiveRecord::RecordNotFound
444 448 render_404
445 449 end
446 450
447 451 def find_project
448 452 @project = Project.find(params[:project_id])
449 453 rescue ActiveRecord::RecordNotFound
450 454 render_404
451 455 end
452 456
453 457 def find_optional_project
454 458 @project = Project.find(params[:project_id]) unless params[:project_id].blank?
455 459 allowed = User.current.allowed_to?({:controller => params[:controller], :action => params[:action]}, @project, :global => true)
456 460 allowed ? true : deny_access
457 461 rescue ActiveRecord::RecordNotFound
458 462 render_404
459 463 end
460 464
461 465 # Retrieve query from session or build a new query
462 466 def retrieve_query
463 467 if !params[:query_id].blank?
464 468 cond = "project_id IS NULL"
465 469 cond << " OR project_id = #{@project.id}" if @project
466 470 @query = Query.find(params[:query_id], :conditions => cond)
467 471 @query.project = @project
468 472 session[:query] = {:id => @query.id, :project_id => @query.project_id}
469 473 else
470 474 if params[:set_filter] || session[:query].nil? || session[:query][:project_id] != (@project ? @project.id : nil)
471 475 # Give it a name, required to be valid
472 476 @query = Query.new(:name => "_")
473 477 @query.project = @project
474 478 if params[:fields] and params[:fields].is_a? Array
475 479 params[:fields].each do |field|
476 480 @query.add_filter(field, params[:operators][field], params[:values][field])
477 481 end
478 482 else
479 483 @query.available_filters.keys.each do |field|
480 484 @query.add_short_filter(field, params[field]) if params[field]
481 485 end
482 486 end
483 487 session[:query] = {:project_id => @query.project_id, :filters => @query.filters}
484 488 else
485 489 @query = Query.find_by_id(session[:query][:id]) if session[:query][:id]
486 490 @query ||= Query.new(:name => "_", :project => @project, :filters => session[:query][:filters])
487 491 @query.project = @project
488 492 end
489 493 end
490 494 end
491 495 end
@@ -1,28 +1,28
1 1 <% if @project.versions.any? %>
2 2 <table class="list">
3 3 <thead>
4 4 <th><%= l(:label_version) %></th>
5 5 <th><%= l(:field_effective_date) %></th>
6 6 <th><%= l(:field_description) %></th>
7 7 <th><%= l(:label_wiki_page) unless @project.wiki.nil? %></th>
8 8 <th style="width:15%"></th>
9 9 <th style="width:15%"></th>
10 10 </thead>
11 11 <tbody>
12 12 <% for version in @project.versions.sort %>
13 13 <tr class="<%= cycle 'odd', 'even' %>">
14 14 <td><%= link_to h(version.name), :controller => 'versions', :action => 'show', :id => version %></td>
15 15 <td align="center"><%= format_date(version.effective_date) %></td>
16 16 <td><%=h version.description %></td>
17 <td><%= link_to(version.wiki_page_title, :controller => 'wiki', :page => Wiki.titleize(version.wiki_page_title)) unless version.wiki_page_title.blank? || @project.wiki.nil? %></td>
17 <td><%= link_to(h(version.wiki_page_title), :controller => 'wiki', :page => Wiki.titleize(version.wiki_page_title)) unless version.wiki_page_title.blank? || @project.wiki.nil? %></td>
18 18 <td align="center"><%= link_to_if_authorized l(:button_edit), { :controller => 'versions', :action => 'edit', :id => version }, :class => 'icon icon-edit' %></td>
19 19 <td align="center"><%= link_to_if_authorized l(:button_delete), {:controller => 'versions', :action => 'destroy', :id => version}, :confirm => l(:text_are_you_sure), :method => :post, :class => 'icon icon-del' %></td>
20 20 </tr>
21 21 <% end; reset_cycle %>
22 22 </tbody>
23 23 </table>
24 24 <% else %>
25 25 <p class="nodata"><%= l(:label_no_data) %></p>
26 26 <% end %>
27 27
28 28 <p><%= link_to_if_authorized l(:label_version_new), :controller => 'projects', :action => 'add_version', :id => @project %></p>
@@ -1,6 +1,6
1 <h2><%=l(:label_role)%>: <%= @role.name %></h2>
1 <h2><%=l(:label_role)%>: <%=h @role.name %></h2>
2 2
3 3 <% labelled_tabular_form_for :role, @role, :url => { :action => 'edit' }, :html => {:id => 'role_form'} do |f| %>
4 4 <%= render :partial => 'form', :locals => { :f => f } %>
5 5 <%= submit_tag l(:button_save) %>
6 6 <% end %>
General Comments 0
You need to be logged in to leave comments. Login now