aboutsummaryrefslogtreecommitdiffstats
path: root/app/models/chouette
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/chouette')
-rw-r--r--app/models/chouette/access_point.rb2
-rw-r--r--app/models/chouette/company.rb1
-rw-r--r--app/models/chouette/connection_link.rb1
-rw-r--r--app/models/chouette/group_of_line.rb1
-rw-r--r--app/models/chouette/journey_pattern.rb1
-rw-r--r--app/models/chouette/line.rb1
-rw-r--r--app/models/chouette/network.rb1
-rw-r--r--app/models/chouette/route.rb2
-rw-r--r--app/models/chouette/stop_area.rb5
-rw-r--r--app/models/chouette/time_table.rb6
-rw-r--r--app/models/chouette/trident_active_record.rb11
-rw-r--r--app/models/chouette/vehicle_journey.rb7
12 files changed, 35 insertions, 4 deletions
diff --git a/app/models/chouette/access_point.rb b/app/models/chouette/access_point.rb
index 43c8e1b3a..317b19b26 100644
--- a/app/models/chouette/access_point.rb
+++ b/app/models/chouette/access_point.rb
@@ -5,6 +5,8 @@ class Chouette::AccessPoint < Chouette::TridentActiveRecord
# FIXME http://jira.codehaus.org/browse/JRUBY-6358
self.primary_key = "id"
include Geokit::Mappable
+ include ProjectionFields
+
has_many :access_links, :dependent => :destroy
belongs_to :stop_area
diff --git a/app/models/chouette/company.rb b/app/models/chouette/company.rb
index d0375b2e6..8ddd4c37d 100644
--- a/app/models/chouette/company.rb
+++ b/app/models/chouette/company.rb
@@ -1,4 +1,5 @@
class Chouette::Company < Chouette::TridentActiveRecord
+ include CompanyRestrictions
has_many :lines
validates_format_of :registration_number, :with => %r{\A[0-9A-Za-z_-]+\Z}, :allow_nil => true, :allow_blank => true
diff --git a/app/models/chouette/connection_link.rb b/app/models/chouette/connection_link.rb
index 045f7c1d9..e225c2fae 100644
--- a/app/models/chouette/connection_link.rb
+++ b/app/models/chouette/connection_link.rb
@@ -1,4 +1,5 @@
class Chouette::ConnectionLink < Chouette::TridentActiveRecord
+ include ConnectionLinkRestrictions
# FIXME http://jira.codehaus.org/browse/JRUBY-6358
self.primary_key = "id"
diff --git a/app/models/chouette/group_of_line.rb b/app/models/chouette/group_of_line.rb
index 1c1ae5f4c..f00db3164 100644
--- a/app/models/chouette/group_of_line.rb
+++ b/app/models/chouette/group_of_line.rb
@@ -1,4 +1,5 @@
class Chouette::GroupOfLine < Chouette::TridentActiveRecord
+ include GroupOfLineRestrictions
# FIXME http://jira.codehaus.org/browse/JRUBY-6358
self.primary_key = "id"
diff --git a/app/models/chouette/journey_pattern.rb b/app/models/chouette/journey_pattern.rb
index d48733edb..9b2b2a9da 100644
--- a/app/models/chouette/journey_pattern.rb
+++ b/app/models/chouette/journey_pattern.rb
@@ -1,4 +1,5 @@
class Chouette::JourneyPattern < Chouette::TridentActiveRecord
+ include JourneyPatternRestrictions
# FIXME http://jira.codehaus.org/browse/JRUBY-6358
self.primary_key = "id"
diff --git a/app/models/chouette/line.rb b/app/models/chouette/line.rb
index d69203233..b1e9940d3 100644
--- a/app/models/chouette/line.rb
+++ b/app/models/chouette/line.rb
@@ -1,4 +1,5 @@
class Chouette::Line < Chouette::TridentActiveRecord
+ include LineRestrictions
# FIXME http://jira.codehaus.org/browse/JRUBY-6358
self.primary_key = "id"
diff --git a/app/models/chouette/network.rb b/app/models/chouette/network.rb
index a631d70ec..c8926506c 100644
--- a/app/models/chouette/network.rb
+++ b/app/models/chouette/network.rb
@@ -1,4 +1,5 @@
class Chouette::Network < Chouette::TridentActiveRecord
+ include NetworkRestrictions
# FIXME http://jira.codehaus.org/browse/JRUBY-6358
self.primary_key = "id"
diff --git a/app/models/chouette/route.rb b/app/models/chouette/route.rb
index d5e39ac12..8949a6bc2 100644
--- a/app/models/chouette/route.rb
+++ b/app/models/chouette/route.rb
@@ -1,4 +1,6 @@
class Chouette::Route < Chouette::TridentActiveRecord
+ include RouteRestrictions
+
# FIXME http://jira.codehaus.org/browse/JRUBY-6358
self.primary_key = "id"
diff --git a/app/models/chouette/stop_area.rb b/app/models/chouette/stop_area.rb
index b7cdd313a..70d2edcbd 100644
--- a/app/models/chouette/stop_area.rb
+++ b/app/models/chouette/stop_area.rb
@@ -5,6 +5,9 @@ class Chouette::StopArea < Chouette::TridentActiveRecord
# FIXME http://jira.codehaus.org/browse/JRUBY-6358
self.primary_key = "id"
include Geokit::Mappable
+ include ProjectionFields
+ include StopAreaRestrictions
+
has_many :stop_points, :dependent => :destroy
has_many :access_points, :dependent => :destroy
has_many :access_links, :dependent => :destroy
@@ -152,7 +155,7 @@ class Chouette::StopArea < Chouette::TridentActiveRecord
def default_position
# for first StopArea ... the bounds is nil :(
- Chouette::StopArea.bounds and Chouette::StopArea.bounds.center
+ Chouette::StopArea.bounds ? Chouette::StopArea.bounds.center : self.referential.envelope.center
end
def self.near(origin, distance = 0.3)
diff --git a/app/models/chouette/time_table.rb b/app/models/chouette/time_table.rb
index 033c39f1c..9af80fbb7 100644
--- a/app/models/chouette/time_table.rb
+++ b/app/models/chouette/time_table.rb
@@ -1,4 +1,5 @@
class Chouette::TimeTable < Chouette::TridentActiveRecord
+ include TimeTableRestrictions
# FIXME http://jira.codehaus.org/browse/JRUBY-6358
self.primary_key = "id"
@@ -29,6 +30,10 @@ class Chouette::TimeTable < Chouette::TridentActiveRecord
validates_associated :dates
validates_associated :periods
+ def presenter
+ @presenter ||= ::TimeTablePresenter.new( self)
+ end
+
def self.start_validity_period
[Chouette::TimeTable.minimum(:start_date)].compact.min
end
@@ -445,6 +450,5 @@ class Chouette::TimeTable < Chouette::TridentActiveRecord
tt.comment = I18n.t("activerecord.copy", :name => self.comment)
tt
end
-
end
diff --git a/app/models/chouette/trident_active_record.rb b/app/models/chouette/trident_active_record.rb
index b89b85863..225d7bb4b 100644
--- a/app/models/chouette/trident_active_record.rb
+++ b/app/models/chouette/trident_active_record.rb
@@ -12,10 +12,19 @@ class Chouette::TridentActiveRecord < Chouette::ActiveRecord
def self.object_id_key
model_name
end
+
+ def referential
+ @referential ||= Referential.where(:slug => Apartment::Tenant.current).first!
+ end
+
+ def hub_restricted?
+ referential.data_format == "hub"
+ end
def prefix
- "NINOXE"
+ self.referential.prefix
end
+
def prepare_auto_columns
# logger.info 'calling before_validation'
# logger.info 'start before_validation : '+self.objectid.to_s
diff --git a/app/models/chouette/vehicle_journey.rb b/app/models/chouette/vehicle_journey.rb
index 44a9f8975..17d4d952f 100644
--- a/app/models/chouette/vehicle_journey.rb
+++ b/app/models/chouette/vehicle_journey.rb
@@ -1,6 +1,6 @@
module Chouette
class VehicleJourney < TridentActiveRecord
-
+ include VehicleJourneyRestrictions
# FIXME http://jira.codehaus.org/browse/JRUBY-6358
self.primary_key = "id"
@@ -43,6 +43,11 @@ module Chouette
accepts_nested_attributes_for :vehicle_journey_at_stops, :allow_destroy => true
+
+ def presenter
+ @presenter ||= ::VehicleJourneyPresenter.new( self)
+ end
+
def transport_mode_name
# return nil if transport_mode is nil
transport_mode && Chouette::TransportMode.new( transport_mode.underscore)