##// END OF EJS Templates
associations loading correction in projects/export_issues_pdf...
Jean-Philippe Lang -
r230:4ff7b395dd7a
parent child
Show More
@@ -1,578 +1,578
1 1 # redMine - project management software
2 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 require 'csv'
19 19
20 20 class ProjectsController < ApplicationController
21 21 layout 'base'
22 22 before_filter :find_project, :authorize, :except => [ :index, :list, :add ]
23 23 before_filter :require_admin, :only => [ :add, :destroy ]
24 24
25 25 helper :sort
26 26 include SortHelper
27 27 helper :custom_fields
28 28 include CustomFieldsHelper
29 29 helper :ifpdf
30 30 include IfpdfHelper
31 31 helper IssuesHelper
32 32 helper :queries
33 33 include QueriesHelper
34 34
35 35 def index
36 36 list
37 37 render :action => 'list' unless request.xhr?
38 38 end
39 39
40 40 # Lists public projects
41 41 def list
42 42 sort_init 'name', 'asc'
43 43 sort_update
44 44 @project_count = Project.count(:all, :conditions => ["is_public=?", true])
45 45 @project_pages = Paginator.new self, @project_count,
46 46 15,
47 47 params['page']
48 48 @projects = Project.find :all, :order => sort_clause,
49 49 :conditions => ["is_public=?", true],
50 50 :limit => @project_pages.items_per_page,
51 51 :offset => @project_pages.current.offset
52 52
53 53 render :action => "list", :layout => false if request.xhr?
54 54 end
55 55
56 56 # Add a new project
57 57 def add
58 58 @custom_fields = IssueCustomField.find(:all)
59 59 @root_projects = Project.find(:all, :conditions => "parent_id is null")
60 60 @project = Project.new(params[:project])
61 61 if request.get?
62 62 @custom_values = ProjectCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @project) }
63 63 else
64 64 @project.custom_fields = CustomField.find(params[:custom_field_ids]) if params[:custom_field_ids]
65 65 @custom_values = ProjectCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @project, :value => params["custom_fields"][x.id.to_s]) }
66 66 @project.custom_values = @custom_values
67 67 if params[:repository_enabled] && params[:repository_enabled] == "1"
68 68 @project.repository = Repository.new
69 69 @project.repository.attributes = params[:repository]
70 70 end
71 71 if @project.save
72 72 flash[:notice] = l(:notice_successful_create)
73 73 redirect_to :controller => 'admin', :action => 'projects'
74 74 end
75 75 end
76 76 end
77 77
78 78 # Show @project
79 79 def show
80 80 @custom_values = @project.custom_values.find(:all, :include => :custom_field)
81 81 @members = @project.members.find(:all, :include => [:user, :role])
82 82 @subprojects = @project.children if @project.children.size > 0
83 83 @news = @project.news.find(:all, :limit => 5, :include => [ :author, :project ], :order => "news.created_on DESC")
84 84 @trackers = Tracker.find(:all, :order => 'position')
85 85 @open_issues_by_tracker = Issue.count(:group => :tracker, :joins => "INNER JOIN issue_statuses ON issue_statuses.id = issues.status_id", :conditions => ["project_id=? and issue_statuses.is_closed=?", @project.id, false])
86 86 @total_issues_by_tracker = Issue.count(:group => :tracker, :conditions => ["project_id=?", @project.id])
87 87 end
88 88
89 89 def settings
90 90 @root_projects = Project::find(:all, :conditions => ["parent_id is null and id <> ?", @project.id])
91 91 @custom_fields = IssueCustomField.find(:all)
92 92 @issue_category ||= IssueCategory.new
93 93 @member ||= @project.members.new
94 94 @roles = Role.find(:all, :order => 'position')
95 95 @users = User.find_active(:all) - @project.users
96 96 @custom_values ||= ProjectCustomField.find(:all).collect { |x| @project.custom_values.find_by_custom_field_id(x.id) || CustomValue.new(:custom_field => x) }
97 97 end
98 98
99 99 # Edit @project
100 100 def edit
101 101 if request.post?
102 102 @project.custom_fields = IssueCustomField.find(params[:custom_field_ids]) if params[:custom_field_ids]
103 103 if params[:custom_fields]
104 104 @custom_values = ProjectCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @project, :value => params["custom_fields"][x.id.to_s]) }
105 105 @project.custom_values = @custom_values
106 106 end
107 107 if params[:repository_enabled]
108 108 case params[:repository_enabled]
109 109 when "0"
110 110 @project.repository = nil
111 111 when "1"
112 112 @project.repository ||= Repository.new
113 113 @project.repository.attributes = params[:repository]
114 114 end
115 115 end
116 116 @project.attributes = params[:project]
117 117 if @project.save
118 118 flash[:notice] = l(:notice_successful_update)
119 119 redirect_to :action => 'settings', :id => @project
120 120 else
121 121 settings
122 122 render :action => 'settings'
123 123 end
124 124 end
125 125 end
126 126
127 127 # Delete @project
128 128 def destroy
129 129 if request.post? and params[:confirm]
130 130 @project.destroy
131 131 redirect_to :controller => 'admin', :action => 'projects'
132 132 end
133 133 end
134 134
135 135 # Add a new issue category to @project
136 136 def add_issue_category
137 137 if request.post?
138 138 @issue_category = @project.issue_categories.build(params[:issue_category])
139 139 if @issue_category.save
140 140 flash[:notice] = l(:notice_successful_create)
141 141 redirect_to :action => 'settings', :tab => 'categories', :id => @project
142 142 else
143 143 settings
144 144 render :action => 'settings'
145 145 end
146 146 end
147 147 end
148 148
149 149 # Add a new version to @project
150 150 def add_version
151 151 @version = @project.versions.build(params[:version])
152 152 if request.post? and @version.save
153 153 flash[:notice] = l(:notice_successful_create)
154 154 redirect_to :action => 'settings', :tab => 'versions', :id => @project
155 155 end
156 156 end
157 157
158 158 # Add a new member to @project
159 159 def add_member
160 160 @member = @project.members.build(params[:member])
161 161 if request.post?
162 162 if @member.save
163 163 flash[:notice] = l(:notice_successful_create)
164 164 redirect_to :action => 'settings', :tab => 'members', :id => @project
165 165 else
166 166 settings
167 167 render :action => 'settings'
168 168 end
169 169 end
170 170 end
171 171
172 172 # Show members list of @project
173 173 def list_members
174 174 @members = @project.members
175 175 end
176 176
177 177 # Add a new document to @project
178 178 def add_document
179 179 @categories = Enumeration::get_values('DCAT')
180 180 @document = @project.documents.build(params[:document])
181 181 if request.post? and @document.save
182 182 # Save the attachments
183 183 params[:attachments].each { |a|
184 184 Attachment.create(:container => @document, :file => a, :author => logged_in_user) unless a.size == 0
185 185 } if params[:attachments] and params[:attachments].is_a? Array
186 186 flash[:notice] = l(:notice_successful_create)
187 187 Mailer.deliver_document_add(@document) if Permission.find_by_controller_and_action(params[:controller], params[:action]).mail_enabled?
188 188 redirect_to :action => 'list_documents', :id => @project
189 189 end
190 190 end
191 191
192 192 # Show documents list of @project
193 193 def list_documents
194 194 @documents = @project.documents.find :all, :include => :category
195 195 end
196 196
197 197 # Add a new issue to @project
198 198 def add_issue
199 199 @tracker = Tracker.find(params[:tracker_id])
200 200 @priorities = Enumeration::get_values('IPRI')
201 201 @issue = Issue.new(:project => @project, :tracker => @tracker)
202 202 if request.get?
203 203 @issue.start_date = Date.today
204 204 @custom_values = @project.custom_fields_for_issues(@tracker).collect { |x| CustomValue.new(:custom_field => x, :customized => @issue) }
205 205 else
206 206 @issue.attributes = params[:issue]
207 207 @issue.author_id = self.logged_in_user.id if self.logged_in_user
208 208 # Multiple file upload
209 209 @attachments = []
210 210 params[:attachments].each { |a|
211 211 @attachments << Attachment.new(:container => @issue, :file => a, :author => logged_in_user) unless a.size == 0
212 212 } if params[:attachments] and params[:attachments].is_a? Array
213 213 @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]) }
214 214 @issue.custom_values = @custom_values
215 215 if @issue.save
216 216 @attachments.each(&:save)
217 217 flash[:notice] = l(:notice_successful_create)
218 218 Mailer.deliver_issue_add(@issue) if Permission.find_by_controller_and_action(params[:controller], params[:action]).mail_enabled?
219 219 redirect_to :action => 'list_issues', :id => @project
220 220 end
221 221 end
222 222 end
223 223
224 224 # Show filtered/sorted issues list of @project
225 225 def list_issues
226 226 sort_init 'issues.id', 'desc'
227 227 sort_update
228 228
229 229 retrieve_query
230 230
231 231 @results_per_page_options = [ 15, 25, 50, 100 ]
232 232 if params[:per_page] and @results_per_page_options.include? params[:per_page].to_i
233 233 @results_per_page = params[:per_page].to_i
234 234 session[:results_per_page] = @results_per_page
235 235 else
236 236 @results_per_page = session[:results_per_page] || 25
237 237 end
238 238
239 239 if @query.valid?
240 240 @issue_count = Issue.count(:include => [:status, :project], :conditions => @query.statement)
241 241 @issue_pages = Paginator.new self, @issue_count, @results_per_page, params['page']
242 242 @issues = Issue.find :all, :order => sort_clause,
243 243 :include => [ :author, :status, :tracker, :project, :priority ],
244 244 :conditions => @query.statement,
245 245 :limit => @issue_pages.items_per_page,
246 246 :offset => @issue_pages.current.offset
247 247 end
248 248 @trackers = Tracker.find :all, :order => 'position'
249 249 render :layout => false if request.xhr?
250 250 end
251 251
252 252 # Export filtered/sorted issues list to CSV
253 253 def export_issues_csv
254 254 sort_init 'issues.id', 'desc'
255 255 sort_update
256 256
257 257 retrieve_query
258 258 render :action => 'list_issues' and return unless @query.valid?
259 259
260 260 @issues = Issue.find :all, :order => sort_clause,
261 261 :include => [ :author, :status, :tracker, :priority, {:custom_values => :custom_field} ],
262 262 :conditions => @query.statement,
263 263 :limit => 500
264 264
265 265 ic = Iconv.new('ISO-8859-1', 'UTF-8')
266 266 export = StringIO.new
267 267 CSV::Writer.generate(export, l(:general_csv_separator)) do |csv|
268 268 # csv header fields
269 269 headers = [ "#", l(:field_status),
270 270 l(:field_tracker),
271 271 l(:field_priority),
272 272 l(:field_subject),
273 273 l(:field_author),
274 274 l(:field_start_date),
275 275 l(:field_due_date),
276 276 l(:field_done_ratio),
277 277 l(:field_created_on),
278 278 l(:field_updated_on)
279 279 ]
280 280 for custom_field in @project.all_custom_fields
281 281 headers << custom_field.name
282 282 end
283 283 csv << headers.collect {|c| ic.iconv(c) }
284 284 # csv lines
285 285 @issues.each do |issue|
286 286 fields = [issue.id, issue.status.name,
287 287 issue.tracker.name,
288 288 issue.priority.name,
289 289 issue.subject,
290 290 issue.author.display_name,
291 291 issue.start_date ? l_date(issue.start_date) : nil,
292 292 issue.due_date ? l_date(issue.due_date) : nil,
293 293 issue.done_ratio,
294 294 l_datetime(issue.created_on),
295 295 l_datetime(issue.updated_on)
296 296 ]
297 297 for custom_field in @project.all_custom_fields
298 298 fields << (show_value issue.custom_value_for(custom_field))
299 299 end
300 300 csv << fields.collect {|c| ic.iconv(c.to_s) }
301 301 end
302 302 end
303 303 export.rewind
304 304 send_data(export.read, :type => 'text/csv; header=present', :filename => 'export.csv')
305 305 end
306 306
307 307 # Export filtered/sorted issues to PDF
308 308 def export_issues_pdf
309 309 sort_init 'issues.id', 'desc'
310 310 sort_update
311 311
312 312 retrieve_query
313 313 render :action => 'list_issues' and return unless @query.valid?
314 314
315 315 @issues = Issue.find :all, :order => sort_clause,
316 :include => [ :author, :status, :tracker, :project, :custom_values ],
316 :include => [ :author, :status, :tracker, :priority ],
317 317 :conditions => @query.statement,
318 318 :limit => 500
319 319
320 320 @options_for_rfpdf ||= {}
321 321 @options_for_rfpdf[:file_name] = "export.pdf"
322 322 render :layout => false
323 323 end
324 324
325 325 def move_issues
326 326 @issues = @project.issues.find(params[:issue_ids]) if params[:issue_ids]
327 327 redirect_to :action => 'list_issues', :id => @project and return unless @issues
328 328 @projects = []
329 329 # find projects to which the user is allowed to move the issue
330 330 @logged_in_user.memberships.each {|m| @projects << m.project if Permission.allowed_to_role("projects/move_issues", m.role_id)}
331 331 # issue can be moved to any tracker
332 332 @trackers = Tracker.find(:all)
333 333 if request.post? and params[:new_project_id] and params[:new_tracker_id]
334 334 new_project = Project.find(params[:new_project_id])
335 335 new_tracker = Tracker.find(params[:new_tracker_id])
336 336 @issues.each { |i|
337 337 # project dependent properties
338 338 unless i.project_id == new_project.id
339 339 i.category = nil
340 340 i.fixed_version = nil
341 341 end
342 342 # move the issue
343 343 i.project = new_project
344 344 i.tracker = new_tracker
345 345 i.save
346 346 }
347 347 flash[:notice] = l(:notice_successful_update)
348 348 redirect_to :action => 'list_issues', :id => @project
349 349 end
350 350 end
351 351
352 352 def add_query
353 353 @query = Query.new(params[:query])
354 354 @query.project = @project
355 355 @query.user = logged_in_user
356 356
357 357 params[:fields].each do |field|
358 358 @query.add_filter(field, params[:operators][field], params[:values][field])
359 359 end if params[:fields]
360 360
361 361 if request.post? and @query.save
362 362 flash[:notice] = l(:notice_successful_create)
363 363 redirect_to :controller => 'reports', :action => 'issue_report', :id => @project
364 364 end
365 365 render :layout => false if request.xhr?
366 366 end
367 367
368 368 # Add a news to @project
369 369 def add_news
370 370 @news = News.new(:project => @project)
371 371 if request.post?
372 372 @news.attributes = params[:news]
373 373 @news.author_id = self.logged_in_user.id if self.logged_in_user
374 374 if @news.save
375 375 flash[:notice] = l(:notice_successful_create)
376 376 redirect_to :action => 'list_news', :id => @project
377 377 end
378 378 end
379 379 end
380 380
381 381 # Show news list of @project
382 382 def list_news
383 383 @news_pages, @news = paginate :news, :per_page => 10, :conditions => ["project_id=?", @project.id], :include => :author, :order => "news.created_on DESC"
384 384 render :action => "list_news", :layout => false if request.xhr?
385 385 end
386 386
387 387 def add_file
388 388 if request.post?
389 389 @version = @project.versions.find_by_id(params[:version_id])
390 390 # Save the attachments
391 391 @attachments = []
392 392 params[:attachments].each { |file|
393 393 next unless file.size > 0
394 394 a = Attachment.create(:container => @version, :file => file, :author => logged_in_user)
395 395 @attachments << a unless a.new_record?
396 396 } if params[:attachments] and params[:attachments].is_a? Array
397 397 Mailer.deliver_attachments_add(@attachments) if !@attachments.empty? and Permission.find_by_controller_and_action(params[:controller], params[:action]).mail_enabled?
398 398 redirect_to :controller => 'projects', :action => 'list_files', :id => @project
399 399 end
400 400 @versions = @project.versions
401 401 end
402 402
403 403 def list_files
404 404 @versions = @project.versions
405 405 end
406 406
407 407 # Show changelog for @project
408 408 def changelog
409 409 @trackers = Tracker.find(:all, :conditions => ["is_in_chlog=?", true], :order => 'position')
410 410 if request.get?
411 411 @selected_tracker_ids = @trackers.collect {|t| t.id.to_s }
412 412 else
413 413 @selected_tracker_ids = params[:tracker_ids].collect { |id| id.to_i.to_s } if params[:tracker_ids] and params[:tracker_ids].is_a? Array
414 414 end
415 415 @selected_tracker_ids ||= []
416 416 @fixed_issues = @project.issues.find(:all,
417 417 :include => [ :fixed_version, :status, :tracker ],
418 418 :conditions => [ "issue_statuses.is_closed=? and issues.tracker_id in (#{@selected_tracker_ids.join(',')}) and issues.fixed_version_id is not null", true],
419 419 :order => "versions.effective_date DESC, issues.id DESC"
420 420 ) unless @selected_tracker_ids.empty?
421 421 @fixed_issues ||= []
422 422 end
423 423
424 424 def roadmap
425 425 @trackers = Tracker.find(:all, :conditions => ["is_in_roadmap=?", true], :order => 'position')
426 426 if request.get?
427 427 @selected_tracker_ids = @trackers.collect {|t| t.id.to_s }
428 428 else
429 429 @selected_tracker_ids = params[:tracker_ids].collect { |id| id.to_i.to_s } if params[:tracker_ids] and params[:tracker_ids].is_a? Array
430 430 end
431 431 @selected_tracker_ids ||= []
432 432 @versions = @project.versions.find(:all,
433 433 :conditions => [ "versions.effective_date>?", Date.today],
434 434 :order => "versions.effective_date ASC"
435 435 )
436 436 end
437 437
438 438 def activity
439 439 if params[:year] and params[:year].to_i > 1900
440 440 @year = params[:year].to_i
441 441 if params[:month] and params[:month].to_i > 0 and params[:month].to_i < 13
442 442 @month = params[:month].to_i
443 443 end
444 444 end
445 445 @year ||= Date.today.year
446 446 @month ||= Date.today.month
447 447
448 448 @date_from = Date.civil(@year, @month, 1)
449 449 @date_to = (@date_from >> 1)-1
450 450
451 451 @events_by_day = {}
452 452
453 453 unless params[:show_issues] == "0"
454 454 @project.issues.find(:all, :include => [:author, :status], :conditions => ["issues.created_on>=? and issues.created_on<=?", @date_from, @date_to] ).each { |i|
455 455 @events_by_day[i.created_on.to_date] ||= []
456 456 @events_by_day[i.created_on.to_date] << i
457 457 }
458 458 @show_issues = 1
459 459 end
460 460
461 461 unless params[:show_news] == "0"
462 462 @project.news.find(:all, :conditions => ["news.created_on>=? and news.created_on<=?", @date_from, @date_to], :include => :author ).each { |i|
463 463 @events_by_day[i.created_on.to_date] ||= []
464 464 @events_by_day[i.created_on.to_date] << i
465 465 }
466 466 @show_news = 1
467 467 end
468 468
469 469 unless params[:show_files] == "0"
470 470 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|
471 471 @events_by_day[i.created_on.to_date] ||= []
472 472 @events_by_day[i.created_on.to_date] << i
473 473 }
474 474 @show_files = 1
475 475 end
476 476
477 477 unless params[:show_documents] == "0"
478 478 @project.documents.find(:all, :conditions => ["documents.created_on>=? and documents.created_on<=?", @date_from, @date_to] ).each { |i|
479 479 @events_by_day[i.created_on.to_date] ||= []
480 480 @events_by_day[i.created_on.to_date] << i
481 481 }
482 482 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|
483 483 @events_by_day[i.created_on.to_date] ||= []
484 484 @events_by_day[i.created_on.to_date] << i
485 485 }
486 486 @show_documents = 1
487 487 end
488 488
489 489 render :layout => false if request.xhr?
490 490 end
491 491
492 492 def calendar
493 493 if params[:year] and params[:year].to_i > 1900
494 494 @year = params[:year].to_i
495 495 if params[:month] and params[:month].to_i > 0 and params[:month].to_i < 13
496 496 @month = params[:month].to_i
497 497 end
498 498 end
499 499 @year ||= Date.today.year
500 500 @month ||= Date.today.month
501 501
502 502 @date_from = Date.civil(@year, @month, 1)
503 503 @date_to = (@date_from >> 1)-1
504 504 # start on monday
505 505 @date_from = @date_from - (@date_from.cwday-1)
506 506 # finish on sunday
507 507 @date_to = @date_to + (7-@date_to.cwday)
508 508
509 509 @issues = @project.issues.find(:all, :include => [:tracker, :status, :assigned_to, :priority], :conditions => ["((start_date>=? and start_date<=?) or (due_date>=? and due_date<=?))", @date_from, @date_to, @date_from, @date_to])
510 510 render :layout => false if request.xhr?
511 511 end
512 512
513 513 def gantt
514 514 if params[:year] and params[:year].to_i >0
515 515 @year_from = params[:year].to_i
516 516 if params[:month] and params[:month].to_i >=1 and params[:month].to_i <= 12
517 517 @month_from = params[:month].to_i
518 518 else
519 519 @month_from = 1
520 520 end
521 521 else
522 522 @month_from ||= (Date.today << 1).month
523 523 @year_from ||= (Date.today << 1).year
524 524 end
525 525
526 526 @zoom = (params[:zoom].to_i > 0 and params[:zoom].to_i < 5) ? params[:zoom].to_i : 2
527 527 @months = (params[:months].to_i > 0 and params[:months].to_i < 25) ? params[:months].to_i : 6
528 528
529 529 @date_from = Date.civil(@year_from, @month_from, 1)
530 530 @date_to = (@date_from >> @months) - 1
531 531 @issues = @project.issues.find(:all, :order => "start_date, due_date", :include => [:tracker, :status, :assigned_to, :priority], :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])
532 532
533 533 if params[:output]=='pdf'
534 534 @options_for_rfpdf ||= {}
535 535 @options_for_rfpdf[:file_name] = "gantt.pdf"
536 536 render :template => "projects/gantt.rfpdf", :layout => false
537 537 else
538 538 render :template => "projects/gantt.rhtml"
539 539 end
540 540 end
541 541
542 542 private
543 543 # Find project of id params[:id]
544 544 # if not found, redirect to project list
545 545 # Used as a before_filter
546 546 def find_project
547 547 @project = Project.find(params[:id])
548 548 @html_title = @project.name
549 549 rescue ActiveRecord::RecordNotFound
550 550 render_404
551 551 end
552 552
553 553 # Retrieve query from session or build a new query
554 554 def retrieve_query
555 555 if params[:query_id]
556 556 @query = @project.queries.find(params[:query_id])
557 557 session[:query] = @query
558 558 else
559 559 if params[:set_filter] or !session[:query] or session[:query].project_id != @project.id
560 560 # Give it a name, required to be valid
561 561 @query = Query.new(:name => "_")
562 562 @query.project = @project
563 563 if params[:fields] and params[:fields].is_a? Array
564 564 params[:fields].each do |field|
565 565 @query.add_filter(field, params[:operators][field], params[:values][field])
566 566 end
567 567 else
568 568 @query.available_filters.keys.each do |field|
569 569 @query.add_short_filter(field, params[field]) if params[field]
570 570 end
571 571 end
572 572 session[:query] = @query
573 573 else
574 574 @query = session[:query]
575 575 end
576 576 end
577 577 end
578 578 end
General Comments 0
You need to be logged in to leave comments. Login now