aboutsummaryrefslogtreecommitdiffstats
path: root/app/controllers
diff options
context:
space:
mode:
authorTeddy Wing2017-05-22 13:58:27 +0200
committerTeddy Wing2017-05-22 13:58:27 +0200
commitd0544404ffd77d276a5db5e8cacc85e26bc5a272 (patch)
tree694a6ddc8ab7015ab304aae06ed9774ffeb30b98 /app/controllers
parentc84330abb5f52d42e1aa7ec9e5db930d8e23163e (diff)
downloadchouette-core-d0544404ffd77d276a5db5e8cacc85e26bc5a272.tar.bz2
VehicleJourneys#index: Handle "no calendar" filter
If specified by the frontend via a `q` sub-parameter, filter out vehicle journeys that don't have associated `TimeTable`s. Split this filter & params check into a separate method to keep the `collection` method a little cleaner. Refs #3427
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/vehicle_journeys_controller.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/app/controllers/vehicle_journeys_controller.rb b/app/controllers/vehicle_journeys_controller.rb
index 5c24652e5..84500bd0c 100644
--- a/app/controllers/vehicle_journeys_controller.rb
+++ b/app/controllers/vehicle_journeys_controller.rb
@@ -96,6 +96,8 @@ class VehicleJourneysController < ChouetteController
)
end
+ scope = filter_without_time_tables(scope)
+
@q = scope.search filtered_ransack_params
@ppage = 20
@@ -105,6 +107,16 @@ class VehicleJourneysController < ChouetteController
@vehicle_journeys
end
+ def filter_without_time_tables(scope)
+ if params[:q] &&
+ params[:q][:vehicle_journey_without_time_table] == 'false'
+ return scope
+ .exclude_journeys_without_time_tables
+ end
+
+ scope
+ end
+
def filtered_ransack_params
if params[:q]
params[:q] = params[:q].reject{|k| params[:q][k] == 'undefined'}