aboutsummaryrefslogtreecommitdiffstats
path: root/app/controllers
diff options
context:
space:
mode:
authorVlatka Pavisic2017-04-11 15:35:01 +0200
committerVlatka Pavisic2017-04-11 15:35:01 +0200
commitaa481c087b162bc775b4418e205f91c5b6bead19 (patch)
tree914ba9b39e0338317bcc2bfd839f745647beda1a /app/controllers
parent8adf909694b52959483818bf839d6e180015eb99 (diff)
downloadchouette-core-aa481c087b162bc775b4418e205f91c5b6bead19.tar.bz2
Refs #3047: Associate RoutingConstraintZone with StopPoints
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/route_stop_points_controller.rb18
-rw-r--r--app/controllers/routing_constraint_zones_controller.rb7
2 files changed, 24 insertions, 1 deletions
diff --git a/app/controllers/route_stop_points_controller.rb b/app/controllers/route_stop_points_controller.rb
new file mode 100644
index 000000000..e12acb33b
--- /dev/null
+++ b/app/controllers/route_stop_points_controller.rb
@@ -0,0 +1,18 @@
+class RouteStopPointsController < ChouetteController
+ defaults resource_class: Chouette::StopPoint
+ actions :index
+ respond_to :json, only: :index
+
+ belongs_to :referential do
+ belongs_to :line, :parent_class => Chouette::Line do
+ belongs_to :route, :parent_class => Chouette::Route
+ end
+ end
+
+ def index
+ respond_to do |format|
+ format.json { render json: referential.lines.find(params[:line_id]).routes.find(params[:route_id]).stop_points.map { |sp| { id: sp.id, name: sp.name } } }
+ end
+ end
+end
+
diff --git a/app/controllers/routing_constraint_zones_controller.rb b/app/controllers/routing_constraint_zones_controller.rb
index bc3dcdfd4..f2f74e801 100644
--- a/app/controllers/routing_constraint_zones_controller.rb
+++ b/app/controllers/routing_constraint_zones_controller.rb
@@ -3,6 +3,8 @@ class RoutingConstraintZonesController < ChouetteController
respond_to :html, :xml, :json
+ before_action :remove_empty_stop_point, only: [:create, :update]
+
belongs_to :referential do
belongs_to :line, parent_class: Chouette::Line
end
@@ -11,7 +13,10 @@ class RoutingConstraintZonesController < ChouetteController
private
def routing_constraint_zone_params
- params.require(:routing_constraint_zone).permit(:name, { stop_area_ids: [] }, :line_id, :route_id, :objectid, :object_version, :creator_id)
+ params.require(:routing_constraint_zone).permit(:name, { stop_point_ids: [] }, :line_id, :route_id, :objectid, :object_version, :creator_id)
end
+ def remove_empty_stop_point
+ params.require(:routing_constraint_zone)[:stop_point_ids].delete('')
+ end
end