diff options
| author | cedricnjanga | 2017-10-03 15:32:26 +0200 |
|---|---|---|
| committer | cedricnjanga | 2017-10-03 16:33:49 +0200 |
| commit | 9ea95b98c52f99494a13befa54cfd8cd298ab0c4 (patch) | |
| tree | 11a795187148a63551b702fb2aecf502975eb9ef /app/controllers/imports_controller.rb | |
| parent | 983f5953d6df7166e91f52ba5eccaf27b8841f76 (diff) | |
| download | chouette-core-9ea95b98c52f99494a13befa54cfd8cd298ab0c4.tar.bz2 | |
Refs #4665
Adapt date filters helpers according to this new concern
Try to correct build error : "ransack period range undefined"
All tests pass on my machine
Refs #4661
Remove string column from ComplianceCheckSet
Diffstat (limited to 'app/controllers/imports_controller.rb')
| -rw-r--r-- | app/controllers/imports_controller.rb | 33 |
1 files changed, 2 insertions, 31 deletions
diff --git a/app/controllers/imports_controller.rb b/app/controllers/imports_controller.rb index 4a12706bc..3c52dc935 100644 --- a/app/controllers/imports_controller.rb +++ b/app/controllers/imports_controller.rb @@ -1,9 +1,7 @@ class ImportsController < BreadcrumbController include PolicyChecker include RansackDateFilter - set_date_param "started_at", DateTime - before_action :set_date_time_params, only: [:index] - + before_action only: [:index] { set_date_time_params("started_at", DateTime) } skip_before_action :authenticate_user!, only: [:download] defaults resource_class: Import, collection_name: 'imports', instance_name: 'import' before_action :ransack_status_params, only: [:index] @@ -52,7 +50,7 @@ class ImportsController < BreadcrumbController def collection scope = parent.imports.where(type: "WorkbenchImport") - scope = ransack_period_range(scope: scope, error_message: t('imports.filters.error_period_filter'), query: :where_started_at_in) + scope = self.ransack_period_range(scope: scope, error_message: t('imports.filters.error_period_filter'), query: :where_started_at_in) @q = scope.search(params[:q]) @@ -65,33 +63,6 @@ class ImportsController < BreadcrumbController private - def ransack_started_at_params - start_date = [] - end_date = [] - - if params[:q] && params[:q][:started_at] && !params[:q][:started_at].has_value?(nil) && !params[:q][:started_at].has_value?("") - [1, 2, 3].each do |key| - start_date << params[:q][:started_at]["begin(#{key}i)"].to_i - end_date << params[:q][:started_at]["end(#{key}i)"].to_i - end - params[:q].delete([:started_at]) - @begin_range = DateTime.new(*start_date,0,0,0) rescue nil - @end_range = DateTime.new(*end_date,23,59,59) rescue nil - end - end - - # Fake ransack filter - # def ransack_period scope - # return scope unless !!@begin_range && !!@end_range - - # if @begin_range > @end_range - # flash.now[:error] = t('imports.filters.error_period_filter') - # else - # scope = scope.where_started_at_between(@begin_range..@end_range) - # end - # scope - # end - def ransack_status_params if params[:q] return params[:q].delete(:status_eq_any) if params[:q][:status_eq_any].empty? || ( (Import.status.values & params[:q][:status_eq_any]).length >= 4 ) |
