diff options
| author | Alban Peignier | 2018-04-25 22:08:53 +0200 |
|---|---|---|
| committer | GitHub | 2018-04-25 22:08:53 +0200 |
| commit | 1434331621f3677ba825da6dc44d438a7df99b70 (patch) | |
| tree | dac15a363ed08962329038c8ea44b7daa67a20be /app/models/chouette | |
| parent | 9fec2b10fa947047e9a8a2f354d232c402b1ef40 (diff) | |
| parent | 5c6718314cbbe3c36fd9343b1ea78124dd2189d3 (diff) | |
| download | chouette-core-1434331621f3677ba825da6dc44d438a7df99b70.tar.bz2 | |
Merge pull request #524 from af83/6762-merge-ignored_routing_contraint_zones
Merge VehicleJourney ignored_routing_contraint_zone_ids. Refs #6762
Diffstat (limited to 'app/models/chouette')
| -rw-r--r-- | app/models/chouette/route.rb | 6 | ||||
| -rw-r--r-- | app/models/chouette/routing_constraint_zone.rb | 7 | ||||
| -rw-r--r-- | app/models/chouette/vehicle_journey.rb | 2 |
3 files changed, 14 insertions, 1 deletions
diff --git a/app/models/chouette/route.rb b/app/models/chouette/route.rb index 928b65f13..0fac53ec0 100644 --- a/app/models/chouette/route.rb +++ b/app/models/chouette/route.rb @@ -148,11 +148,15 @@ module Chouette values = self.slice(*['name', 'published_name', 'wayback']).values values.tap do |attrs| attrs << self.stop_points.sort_by(&:position).map{|sp| [sp.stop_area.user_objectid, sp.for_boarding, sp.for_alighting]} - attrs << self.routing_constraint_zones.map(&:checksum).sort + + routing_constraint_zones = self.routing_constraint_zones + routing_constraint_zones += Chouette::RoutingConstraintZone.with_stop_points_contained_in(self.stop_points) unless self.new_record? + attrs << routing_constraint_zones.uniq.map(&:checksum).sort end end has_checksum_children StopPoint + has_checksum_children RoutingConstraintZone def geometry points = stop_areas.map(&:to_lat_lng).compact.map do |loc| diff --git a/app/models/chouette/routing_constraint_zone.rb b/app/models/chouette/routing_constraint_zone.rb index 6b7c228b0..671ce2871 100644 --- a/app/models/chouette/routing_constraint_zone.rb +++ b/app/models/chouette/routing_constraint_zone.rb @@ -7,6 +7,13 @@ module Chouette belongs_to :route has_array_of :stop_points, class_name: 'Chouette::StopPoint' + belongs_to_array_in_many :vehicle_journeys, class_name: 'Chouette::VehicleJourney', array_name: :ignored_routing_contraint_zones + + def update_vehicle_journey_checksums + vehicle_journeys.each(&:update_checksum!) + end + after_save :update_vehicle_journey_checksums + validates_presence_of :name, :stop_points, :route_id # validates :stop_point_ids, length: { minimum: 2, too_short: I18n.t('activerecord.errors.models.routing_constraint_zone.attributes.stop_points.not_enough_stop_points') } validate :stop_points_belong_to_route, :not_all_stop_points_selected diff --git a/app/models/chouette/vehicle_journey.rb b/app/models/chouette/vehicle_journey.rb index b5476c210..74d875164 100644 --- a/app/models/chouette/vehicle_journey.rb +++ b/app/models/chouette/vehicle_journey.rb @@ -25,6 +25,7 @@ module Chouette has_and_belongs_to_many :footnotes, :class_name => 'Chouette::Footnote' has_and_belongs_to_many :purchase_windows, :class_name => 'Chouette::PurchaseWindow' + has_array_of :ignored_routing_contraint_zones, class_name: 'Chouette::RoutingConstraintZone' validates_presence_of :route validates_presence_of :journey_pattern @@ -146,6 +147,7 @@ module Chouette attrs << vjas.uniq.sort_by { |s| s.stop_point&.position }.map(&:checksum).sort attrs << self.purchase_windows.map(&:checksum).sort if purchase_windows.present? + attrs << ignored_routing_contraint_zones.map(&:checksum).sort if ignored_routing_contraint_zones.present? end end |
