aboutsummaryrefslogtreecommitdiffstats
path: root/app/controllers
diff options
context:
space:
mode:
authorTeddy Wing2017-06-14 18:37:50 +0200
committerTeddy Wing2017-06-14 18:37:50 +0200
commit467f787eb36b68f809409ec3a01797af30fe5128 (patch)
treec356ce51ba8990f86a3ecce737985442f9d1e602 /app/controllers
parent8c9eb5e1108f4d7e182c9984d667ed7cf4adc006 (diff)
parentb7fac062e4a0fcaf485ff7c848f161f99f020a5f (diff)
downloadchouette-core-467f787eb36b68f809409ec3a01797af30fe5128.tar.bz2
Merge remote-tracking branch 'origin/master' into 3479-refactor-table_builder-helper
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/route_stop_points_controller.rb3
-rw-r--r--app/controllers/routing_constraint_zones_controller.rb15
2 files changed, 13 insertions, 5 deletions
diff --git a/app/controllers/route_stop_points_controller.rb b/app/controllers/route_stop_points_controller.rb
index e12acb33b..730bd08a9 100644
--- a/app/controllers/route_stop_points_controller.rb
+++ b/app/controllers/route_stop_points_controller.rb
@@ -11,8 +11,7 @@ class RouteStopPointsController < ChouetteController
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 } } }
+ format.json { render json: referential.lines.find(params[:line_id]).routes.find(params[:route_id]).stop_points.map { |sp| { id: sp.id, stop_area_id: sp.stop_area.id, name: sp.name, zip_code: sp.stop_area.zip_code, city_name: sp.stop_area.city_name } } }
end
end
end
-
diff --git a/app/controllers/routing_constraint_zones_controller.rb b/app/controllers/routing_constraint_zones_controller.rb
index b5072f401..7707427b0 100644
--- a/app/controllers/routing_constraint_zones_controller.rb
+++ b/app/controllers/routing_constraint_zones_controller.rb
@@ -4,7 +4,7 @@ class RoutingConstraintZonesController < ChouetteController
defaults resource_class: Chouette::RoutingConstraintZone
respond_to :html, :xml, :json
- before_action :remove_empty_stop_point, only: [:create, :update]
+ before_action :check_stoppoint_param, only: [:create, :update]
belongs_to :referential do
belongs_to :line, parent_class: Chouette::Line
@@ -56,7 +56,16 @@ class RoutingConstraintZonesController < ChouetteController
)
end
- def remove_empty_stop_point
- params.require(:routing_constraint_zone)[:stop_point_ids].delete('')
+ def check_stoppoint_param
+ spArr = []
+ if params.require(:routing_constraint_zone)[:stop_point_ids] and params.require(:routing_constraint_zone)[:stop_point_ids].length >= 2
+ params.require(:routing_constraint_zone)[:stop_point_ids].each do |k,v|
+ spArr << v
+ end
+ params.require(:routing_constraint_zone)[:stop_point_ids] = spArr
+ else
+ Rails.logger.error("Error: An ITL must have at least two stop points")
+ end
end
+
end