aboutsummaryrefslogtreecommitdiffstats
path: root/app/models
diff options
context:
space:
mode:
authorcedricnjanga2017-09-29 15:40:37 +0200
committercedricnjanga2017-09-29 16:44:31 +0200
commite50707e425bbece28273d7f3a2cff3e8b5cd3ccb (patch)
tree716c6d54459151ecd98da28fdca46be1b6268ce0 /app/models
parent04618f6079aabca0d8e5464bc8c1701c15a593fa (diff)
downloadchouette-core-e50707e425bbece28273d7f3a2cff3e8b5cd3ccb.tar.bz2
Refs Adapt transport mode & submode translations
Diffstat (limited to 'app/models')
-rw-r--r--app/models/chouette/line.rb4
-rw-r--r--app/models/chouette/transport_mode.rb71
-rw-r--r--app/models/line_referential.rb6
-rw-r--r--app/models/organisation.rb2
-rw-r--r--app/models/rule_parameter_set.rb3
-rw-r--r--app/models/stif_transport_mode_enumerations.rb5
6 files changed, 6 insertions, 85 deletions
diff --git a/app/models/chouette/line.rb b/app/models/chouette/line.rb
index 63d2d1606..6f87a5d08 100644
--- a/app/models/chouette/line.rb
+++ b/app/models/chouette/line.rb
@@ -3,12 +3,10 @@ class Chouette::Line < Chouette::ActiveRecord
include LineRestrictions
include LineReferentialSupport
include StifTransportModeEnumerations
+ include StifTransportSubmodeEnumerations
- extend Enumerize
extend ActiveModel::Naming
- enumerize :transport_submode, in: %i(unknown undefined internationalFlight domesticFlight intercontinentalFlight domesticScheduledFlight shuttleFlight intercontinentalCharterFlight internationalCharterFlight roundTripCharterFlight sightseeingFlight helicopterService domesticCharterFlight SchengenAreaFlight airshipService shortHaulInternationalFlight canalBarge localBus regionalBus expressBus nightBus postBus specialNeedsBus mobilityBus mobilityBusForRegisteredDisabled sightseeingBus shuttleBus highFrequencyBus dedicatedLaneBus schoolBus schoolAndPublicServiceBus railReplacementBus demandAndResponseBus airportLinkBus internationalCoach nationalCoach shuttleCoach regionalCoach specialCoach schoolCoach sightseeingCoach touristCoach commuterCoach metro tube urbanRailway local highSpeedRail suburbanRailway regionalRail interregionalRail longDistance intermational sleeperRailService nightRail carTransportRailService touristRailway railShuttle replacementRailService specialTrain crossCountryRail rackAndPinionRailway cityTram localTram regionalTram sightseeingTram shuttleTram trainTram internationalCarFerry nationalCarFerry regionalCarFerry localCarFerry internationalPassengerFerry nationalPassengerFerry regionalPassengerFerry localPassengerFerry postBoat trainFerry roadFerryLink airportBoatLink highSpeedVehicleService highSpeedPassengerService sightseeingService schoolBoat cableFerry riverBus scheduledFerry shuttleFerryService telecabin cableCar lift chairLift dragLift telecabinLink funicular streetCableCar allFunicularServices undefinedFunicular)
-
# FIXME http://jira.codehaus.org/browse/JRUBY-6358
self.primary_key = "id"
diff --git a/app/models/chouette/transport_mode.rb b/app/models/chouette/transport_mode.rb
deleted file mode 100644
index 825ef15b8..000000000
--- a/app/models/chouette/transport_mode.rb
+++ /dev/null
@@ -1,71 +0,0 @@
-class Chouette::TransportMode < ActiveSupport::StringInquirer
-
- def initialize(text_code, numerical_code)
- super text_code.to_s
- @numerical_code = numerical_code
- end
-
- def self.new(text_code, numerical_code = nil)
- if text_code and numerical_code
- super
- elsif self === text_code
- text_code
- else
- if Fixnum === text_code
- text_code, numerical_code = definitions.rassoc(text_code)
- else
- text_code, numerical_code = definitions.assoc(text_code.to_s)
- end
-
- super text_code, numerical_code
- end
- end
-
- def to_i
- @numerical_code
- end
-
- def inspect
- "#{to_s}/#{to_i}"
- end
-
- def name
- camelize
- end
-
- @@definitions = [
- ["interchange", -1],
- ["unknown", 0],
- ["coach", 1],
- ["air", 2],
- ["waterborne", 3],
- ["bus", 4],
- ["ferry", 5],
- ["walk", 6],
- ["metro", 7],
- ["shuttle", 8],
- ["rapid_transit", 9],
- ["taxi", 10],
- ["local_train", 11],
- ["train", 12],
- ["long_distance_train", 13],
- ["tramway", 14],
- ["trolleybus", 15],
- ["private_vehicle", 16],
- ["bicycle", 17],
- ["other", 18]
- ]
- cattr_reader :definitions
-
- @@all = nil
- def self.all
- @@all ||= definitions.collect do |text_code, numerical_code|
- new(text_code, numerical_code)
- end
- end
-
- def public_transport?
- not interchange?
- end
-
-end
diff --git a/app/models/line_referential.rb b/app/models/line_referential.rb
index 8bbc32993..7ab892b53 100644
--- a/app/models/line_referential.rb
+++ b/app/models/line_referential.rb
@@ -1,4 +1,6 @@
class LineReferential < ActiveRecord::Base
+ include StifTransportModeEnumerations
+
has_many :line_referential_memberships
has_many :organisations, through: :line_referential_memberships
has_many :lines, class_name: 'Chouette::Line'
@@ -25,8 +27,4 @@ class LineReferential < ActiveRecord::Base
def last_sync
line_referential_syncs.last
end
-
- def transport_modes
- Chouette::TransportMode.all.select { |tm| tm.to_i > 0 }
- end
end
diff --git a/app/models/organisation.rb b/app/models/organisation.rb
index ba65ad375..ffbbdd542 100644
--- a/app/models/organisation.rb
+++ b/app/models/organisation.rb
@@ -19,7 +19,7 @@ class Organisation < ActiveRecord::Base
validates_presence_of :name
validates_uniqueness_of :code
- after_create :add_rule_parameter_set
+ # after_create :add_rule_parameter_set
def add_rule_parameter_set
RuleParameterSet.default_for_all_modes( self).save
diff --git a/app/models/rule_parameter_set.rb b/app/models/rule_parameter_set.rb
index db78a2f8a..122483711 100644
--- a/app/models/rule_parameter_set.rb
+++ b/app/models/rule_parameter_set.rb
@@ -65,7 +65,8 @@ class RuleParameterSet < ActiveRecord::Base
end
def self.all_modes
- Chouette::TransportMode.all.map { |m| m.to_s}
+ # Chouette::TransportMode.all.map { |m| m.to_s}
+ []
end
def self.mode_attribute?( method_name )
diff --git a/app/models/stif_transport_mode_enumerations.rb b/app/models/stif_transport_mode_enumerations.rb
deleted file mode 100644
index a9a3fc3e0..000000000
--- a/app/models/stif_transport_mode_enumerations.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-module StifTransportModeEnumerations
- extend Enumerize
-
- enumerize :transport_mode, in: %w(air bus coach ferry metro rail trolleyBus tram water cableway funicular other)
-end