app/models/chouette/route.rb in ninoxe-1.1.5 vs app/models/chouette/route.rb in ninoxe-1.2.0
- old
+ new
@@ -3,15 +3,15 @@
self.primary_key = "id"
attr_accessor :wayback_code
attr_accessor :direction_code
- attr_accessible :direction_code, :wayback_code, :line_id, :objectid, :object_version, :creation_time, :creator_id, :name
- attr_accessible :comment, :opposite_route_id, :published_name, :number, :direction, :wayback, :stop_points_attributes
+ # attr_accessible :direction_code, :wayback_code, :line_id, :objectid, :object_version, :creation_time, :creator_id, :name
+ # attr_accessible :comment, :opposite_route_id, :published_name, :number, :direction, :wayback, :stop_points_attributes
def self.nullable_attributes
- [:published_name, :comment, :number]
+ [:published_name, :comment, :number, :name]
end
belongs_to :line
has_many :journey_patterns, :dependent => :destroy
@@ -19,11 +19,11 @@
def timeless
all( :conditions => ['vehicle_journeys.id NOT IN (?)', Chouette::VehicleJourneyAtStop.where( :stop_point_id => proxy_association.owner.journey_patterns.pluck( :departure_stop_point_id)).pluck(:vehicle_journey_id)] )
end
end
belongs_to :opposite_route, :class_name => 'Chouette::Route', :foreign_key => :opposite_route_id
- has_many :stop_points, :order => 'position', :dependent => :destroy do
+ has_many :stop_points, -> { order('position ASC') }, :dependent => :destroy do
def find_by_stop_area(stop_area)
stop_area_ids = Integer === stop_area ? [stop_area] : (stop_area.children_in_depth + [stop_area]).map(&:id)
where( :stop_area_id => stop_area_ids).first or
raise ActiveRecord::RecordNotFound.new("Can't find a StopArea #{stop_area.inspect} in Route #{proxy_owner.id.inspect}'s StopPoints")
end
@@ -42,24 +42,24 @@
end
end
where(" position between ? and ? ", between_positions.first, between_positions.last)
end
end
- has_many :stop_areas, :through => :stop_points, :order => 'stop_points.position' do
+ has_many :stop_areas, -> { order('stop_points.position ASC') }, :through => :stop_points do
def between(departure, arrival)
departure, arrival = [departure, arrival].collect do |endpoint|
String === endpoint ? Chouette::StopArea.find_by_objectid(endpoint) : endpoint
end
proxy_owner.stop_points.between(departure, arrival).includes(:stop_area).collect(&:stop_area)
end
end
accepts_nested_attributes_for :stop_points, :allow_destroy => :true
- validates_presence_of :name
+ # validates_presence_of :name
validates_presence_of :line
- validates_presence_of :direction_code
- validates_presence_of :wayback_code
+ # validates_presence_of :direction_code
+ # validates_presence_of :wayback_code
before_destroy :dereference_opposite_route
def geometry_presenter
Chouette::Geometry::RoutePresenter.new self
@@ -81,11 +81,11 @@
def time_tables
self.vehicle_journeys.joins(:time_tables).map(&:"time_tables").flatten.uniq
end
def sorted_vehicle_journeys
- vehicle_journeys.includes( :vehicle_journey_at_stops, :journey_pattern).where( "vehicle_journey_at_stops.stop_point_id=journey_patterns.departure_stop_point_id").order( "vehicle_journey_at_stops.departure_time")
+ vehicle_journeys.joins(:journey_pattern, :vehicle_journey_at_stops).where("vehicle_journey_at_stops.stop_point_id=journey_patterns.departure_stop_point_id").order( "vehicle_journey_at_stops.departure_time")
end
def self.direction_binding
{ "A" => "straight_forward",
"R" => "backward",
@@ -158,6 +158,5 @@
end
return true
end
end
-