aboutsummaryrefslogtreecommitdiffstats
path: root/app/controllers/vehicle_journeys_controller.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/vehicle_journeys_controller.rb')
-rw-r--r--app/controllers/vehicle_journeys_controller.rb27
1 files changed, 27 insertions, 0 deletions
diff --git a/app/controllers/vehicle_journeys_controller.rb b/app/controllers/vehicle_journeys_controller.rb
new file mode 100644
index 000000000..3a99d531b
--- /dev/null
+++ b/app/controllers/vehicle_journeys_controller.rb
@@ -0,0 +1,27 @@
+class VehicleJourneysController < ChouetteController
+ defaults :resource_class => Chouette::VehicleJourney
+
+ belongs_to :referential do
+ belongs_to :line, :parent_class => Chouette::Line do
+ belongs_to :route, :parent_class => Chouette::Route
+ end
+ end
+
+ protected
+
+ def collection
+ @q = parent.vehicle_journeys.search(params[:q])
+ @vehicle_journeys ||= @q.result(:distinct => true).paginate(:page => params[:page], :per_page => 10)
+ @matrix ||= matrix
+ end
+
+ def matrix
+ {}.tap do |hash|
+ @vehicle_journeys.each do |vj|
+ vj.vehicle_journey_at_stops.each do |vjas|
+ hash[ "#{vj.id}-#{vjas.stop_point_id}"] = vjas
+ end
+ end
+ end
+ end
+end