aboutsummaryrefslogtreecommitdiffstats
path: root/app/models/referential.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/referential.rb')
-rw-r--r--app/models/referential.rb60
1 files changed, 33 insertions, 27 deletions
diff --git a/app/models/referential.rb b/app/models/referential.rb
index 91a88d02d..78b719fab 100644
--- a/app/models/referential.rb
+++ b/app/models/referential.rb
@@ -1,5 +1,5 @@
# coding: utf-8
-class Referential < ActiveRecord::Base
+class Referential < ApplicationModel
include DataFormatEnumerations
include ObjectidFormatterSupport
@@ -78,31 +78,29 @@ class Referential < ActiveRecord::Base
alias_method_chain :save, :table_lock_timeout
- if Rails.env.development?
- def self.force_register_models_with_checksum
- paths = Rails.application.paths['app/models'].to_a
- Rails.application.railties.each do |tie|
- next unless tie.respond_to? :paths
- paths += tie.paths['app/models'].to_a
- end
+ def self.force_register_models_with_checksum
+ paths = Rails.application.paths['app/models'].to_a
+ Rails.application.railties.each do |tie|
+ next unless tie.respond_to? :paths
+ paths += tie.paths['app/models'].to_a
+ end
- paths.each do |path|
- next unless File.directory?(path)
- Dir.chdir path do
- Dir['**/*.rb'].each do |src|
- next if src =~ /^concerns/
- # thanks for inconsistent naming ...
- if src == "route_control/zdl_stop_area.rb"
- RouteControl::ZDLStopArea
- next
- end
- Rails.logger.info "Loading #{src}"
- begin
- src[0..-4].classify.safe_constantize
- rescue => e
- Rails.logger.info "Failed: #{e.message}"
- nil
- end
+ paths.each do |path|
+ next unless File.directory?(path)
+ Dir.chdir path do
+ Dir['**/*.rb'].each do |src|
+ next if src =~ /^concerns/
+ # thanks for inconsistent naming ...
+ if src == "route_control/zdl_stop_area.rb"
+ RouteControl::ZDLStopArea
+ next
+ end
+ Rails.logger.info "Loading #{src}"
+ begin
+ src[0..-4].classify.safe_constantize
+ rescue => e
+ Rails.logger.info "Failed: #{e.message}"
+ nil
end
end
end
@@ -168,6 +166,10 @@ class Referential < ActiveRecord::Base
Chouette::TimeTable.all
end
+ def time_table_dates
+ Chouette::TimeTableDate.all
+ end
+
def timebands
Chouette::Timeband.all
end
@@ -184,6 +186,10 @@ class Referential < ActiveRecord::Base
Chouette::VehicleJourneyFrequency.all
end
+ def vehicle_journey_at_stops
+ Chouette::VehicleJourneyAtStop.all
+ end
+
def routing_constraint_zones
Chouette::RoutingConstraintZone.all
end
@@ -233,7 +239,7 @@ class Referential < ActiveRecord::Base
end
end
- def self.new_from(from, functional_scope)
+ def self.new_from(from, organisation)
Referential.new(
name: I18n.t("activerecord.copy", name: from.name),
slug: "#{from.slug}_clone",
@@ -244,7 +250,7 @@ class Referential < ActiveRecord::Base
stop_area_referential: from.stop_area_referential,
created_from: from,
objectid_format: from.objectid_format,
- metadatas: from.metadatas.map { |m| ReferentialMetadata.new_from(m, functional_scope) }
+ metadatas: from.metadatas.map { |m| ReferentialMetadata.new_from(m, organisation) }
)
end