diff options
| author | Vlatka Pavisic | 2017-04-05 12:14:25 +0200 |
|---|---|---|
| committer | Vlatka Pavisic | 2017-04-05 12:14:30 +0200 |
| commit | 81f5ee3810fd30f0bccd8a0f33245b0444ebadd9 (patch) | |
| tree | 2c25b2dfab7c2761e033163578d6c33d97e8f391 /app | |
| parent | 1e5a595150f4a90dcf17e0e6cd32728486fb36b8 (diff) | |
| download | chouette-core-81f5ee3810fd30f0bccd8a0f33245b0444ebadd9.tar.bz2 | |
Refs #3036 : Associate RoutingConstraintZone with Route and not Line
Diffstat (limited to 'app')
| -rw-r--r-- | app/controllers/routing_constraint_zones_controller.rb | 2 | ||||
| -rw-r--r-- | app/helpers/newapplication_helper.rb | 3 | ||||
| -rw-r--r-- | app/models/chouette/line.rb | 3 | ||||
| -rw-r--r-- | app/models/chouette/route.rb | 1 | ||||
| -rw-r--r-- | app/models/chouette/routing_constraint_zone.rb | 4 | ||||
| -rw-r--r-- | app/views/routing_constraint_zones/_form.html.slim | 3 | ||||
| -rw-r--r-- | app/views/routing_constraint_zones/index.html.slim | 2 | ||||
| -rw-r--r-- | app/views/routing_constraint_zones/show.html.slim | 4 |
8 files changed, 14 insertions, 8 deletions
diff --git a/app/controllers/routing_constraint_zones_controller.rb b/app/controllers/routing_constraint_zones_controller.rb index c39c50326..bc3dcdfd4 100644 --- a/app/controllers/routing_constraint_zones_controller.rb +++ b/app/controllers/routing_constraint_zones_controller.rb @@ -11,7 +11,7 @@ class RoutingConstraintZonesController < ChouetteController private def routing_constraint_zone_params - params.require(:routing_constraint_zone).permit(:name, { stop_area_ids: [] }, :line_id, :objectid, :object_version, :creator_id) + params.require(:routing_constraint_zone).permit(:name, { stop_area_ids: [] }, :line_id, :route_id, :objectid, :object_version, :creator_id) end end diff --git a/app/helpers/newapplication_helper.rb b/app/helpers/newapplication_helper.rb index c9da544d1..c4b8ee7ab 100644 --- a/app/helpers/newapplication_helper.rb +++ b/app/helpers/newapplication_helper.rb @@ -30,6 +30,7 @@ module NewapplicationHelper body = content_tag :tbody do collection.collect do |item| + content_tag :tr do bcont = [] @@ -54,6 +55,7 @@ module NewapplicationHelper if current_referential lnk << current_referential lnk << item.line if item.respond_to? :line + lnk << item.route.line if item.class.to_s == 'Chouette::RoutingConstraintZone' lnk << item if item.class.to_s == 'Chouette::RoutingConstraintZone' lnk << item if item.respond_to? :line_referential lnk << item.stop_area if item.respond_to? :stop_area @@ -105,6 +107,7 @@ module NewapplicationHelper if current_referential polymorph_url << current_referential polymorph_url << item.line if item.respond_to? :line + polymorph_url << item.route.line if item.class.to_s == 'Chouette::RoutingConstraintZone' polymorph_url << item if item.class.to_s == 'Chouette::RoutingConstraintZone' polymorph_url << item if item.respond_to? :line_referential polymorph_url << item.stop_area if item.respond_to? :stop_area diff --git a/app/models/chouette/line.rb b/app/models/chouette/line.rb index 27a37a7f4..50dd9b1b3 100644 --- a/app/models/chouette/line.rb +++ b/app/models/chouette/line.rb @@ -20,14 +20,13 @@ class Chouette::Line < Chouette::ActiveRecord has_many :routes, :dependent => :destroy has_many :journey_patterns, :through => :routes has_many :vehicle_journeys, :through => :journey_patterns + has_many :routing_constraint_zones, through: :routes has_and_belongs_to_many :group_of_lines, :class_name => 'Chouette::GroupOfLine', :order => 'group_of_lines.name' has_many :footnotes, :inverse_of => :line, :validate => :true, :dependent => :destroy accepts_nested_attributes_for :footnotes, :reject_if => :all_blank, :allow_destroy => true - has_many :routing_constraint_zones - attr_reader :group_of_line_tokens # validates_presence_of :network diff --git a/app/models/chouette/route.rb b/app/models/chouette/route.rb index 9de7d7470..688f8774e 100644 --- a/app/models/chouette/route.rb +++ b/app/models/chouette/route.rb @@ -16,6 +16,7 @@ class Chouette::Route < Chouette::TridentActiveRecord belongs_to :line + has_many :routing_constraint_zones has_many :journey_patterns, :dependent => :destroy has_many :vehicle_journeys, :dependent => :destroy do def timeless diff --git a/app/models/chouette/routing_constraint_zone.rb b/app/models/chouette/routing_constraint_zone.rb index 681069416..2c8583ec1 100644 --- a/app/models/chouette/routing_constraint_zone.rb +++ b/app/models/chouette/routing_constraint_zone.rb @@ -1,8 +1,8 @@ class Chouette::RoutingConstraintZone < Chouette::TridentActiveRecord - belongs_to :line + belongs_to :route has_array_of :stop_areas, class_name: 'Chouette::StopArea' - validates_presence_of :name, :stop_area_ids, :line_id + validates_presence_of :name, :stop_area_ids, :route_id validates :stop_areas, length: { minimum: 2 } self.primary_key = 'id' diff --git a/app/views/routing_constraint_zones/_form.html.slim b/app/views/routing_constraint_zones/_form.html.slim index afc993a0f..f72dd1471 100644 --- a/app/views/routing_constraint_zones/_form.html.slim +++ b/app/views/routing_constraint_zones/_form.html.slim @@ -4,6 +4,9 @@ = f.input :name .row .col-lg-6.col-sm-12 + = f.input :route_id, collection: @line.routes + .row + .col-lg-6.col-sm-12 / Temporarily limit the collection to 10 items... otherwise it kills RoR = f.input :stop_area_ids, as: :select, collection: Chouette::StopArea.limit(10), selected: @routing_constraint_zone.stop_area_ids, label: Chouette::StopArea.model_name.human.pluralize.capitalize, label_method: :name, input_html: { 'data-select2ed': 'true', 'data-select2ed-placeholder': 'SĂ©lection de arrĂȘts', 'multiple': 'multiple', style: 'width: 100%' } diff --git a/app/views/routing_constraint_zones/index.html.slim b/app/views/routing_constraint_zones/index.html.slim index 9061fbdfd..e8da0f974 100644 --- a/app/views/routing_constraint_zones/index.html.slim +++ b/app/views/routing_constraint_zones/index.html.slim @@ -1,7 +1,7 @@ = title_tag Chouette::RoutingConstraintZone.model_name.human.pluralize(:fr) - if policy(Chouette::RoutingConstraintZone).create? && @referential.organisation == current_organisation - = link_to t('routing_constraint_zones.actions.new'), new_referential_line_routing_constraint_zone_path + = link_to t('routing_constraint_zones.actions.new'), new_referential_line_routing_constraint_zone_path(@referential, @line) - if @routing_constraint_zones.any? = table_builder @routing_constraint_zones, diff --git a/app/views/routing_constraint_zones/show.html.slim b/app/views/routing_constraint_zones/show.html.slim index 0f88f5b3f..7b7b63623 100644 --- a/app/views/routing_constraint_zones/show.html.slim +++ b/app/views/routing_constraint_zones/show.html.slim @@ -5,8 +5,8 @@ p = @routing_constraint_zone.name p - label => "#{Chouette::Line.model_name.human.capitalize} : " - = link_to @routing_constraint_zone.line.name, referential_line_path(@referential, @line) + label => "#{Chouette::Route.model_name.human.capitalize} : " + = link_to @routing_constraint_zone.route.name, referential_line_route_path(@referential, @line, @routing_constraint_zone.route) p label => "#{Chouette::StopArea.model_name.human.pluralize.capitalize} : " |
