diff options
| author | cedricnjanga | 2017-12-20 09:24:45 +0100 |
|---|---|---|
| committer | Luc Donnet | 2017-12-21 13:57:03 +0100 |
| commit | b6606b25148b958a1f8d5502d95c7db12ef224b0 (patch) | |
| tree | 1abca4c4cd646830a37f30cc8fb15eceb242b5bc /app/controllers/purchase_windows_controller.rb | |
| parent | e3f7317345555584464c93ce81423d3defd82d57 (diff) | |
| download | chouette-core-b6606b25148b958a1f8d5502d95c7db12ef224b0.tar.bz2 | |
Fix purchase window date filter
Diffstat (limited to 'app/controllers/purchase_windows_controller.rb')
| -rw-r--r-- | app/controllers/purchase_windows_controller.rb | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/app/controllers/purchase_windows_controller.rb b/app/controllers/purchase_windows_controller.rb index b676623ae..a70535150 100644 --- a/app/controllers/purchase_windows_controller.rb +++ b/app/controllers/purchase_windows_controller.rb @@ -2,7 +2,7 @@ class PurchaseWindowsController < ChouetteController include ReferentialSupport include RansackDateFilter include PolicyChecker - before_action only: [:index] { set_date_time_params("bounding_dates", Date) } + before_action :ransack_contains_date, only: [:index] defaults :resource_class => Chouette::PurchaseWindow, collection_name: 'purchase_windows', instance_name: 'purchase_window' belongs_to :referential @@ -44,4 +44,15 @@ class PurchaseWindowsController < ChouetteController } ) end + + def ransack_contains_date + date =[] + if params[:q] && !params[:q]['date_ranges(1i)'].empty? + ['date_ranges(1i)', 'date_ranges(2i)', 'date_ranges(3i)'].each do |key| + date << params[:q][key].to_i + params[:q].delete(key) + end + params[:q]['date_ranges'] = Date.new(*date) rescue nil + end + end end |
