aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorRobert2018-01-09 18:45:26 +0100
committerAlban Peignier2018-01-10 17:47:10 +0100
commita7fe8da0bc230ee7f5d3173454fc07b596970d13 (patch)
tree9b698c4d1d8c2bc1eecceaeed0f25ce76088392a /app
parentfd553851e9e6c59b998eef8577836a954c4d43f3 (diff)
downloadchouette-core-a7fe8da0bc230ee7f5d3173454fc07b596970d13.tar.bz2
Fixes: #5505@2h; Migrations, specs and implementations
- Migration index_resource_type_on_custom_fields - Specing behavior of custom field's resource (VehicleJourney) - Migration create json col custom_field_values for resource (VehicleJourney) - Create accessor methods inside resource (VehicleJourney)
Diffstat (limited to 'app')
-rw-r--r--app/models/chouette/vehicle_journey.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/app/models/chouette/vehicle_journey.rb b/app/models/chouette/vehicle_journey.rb
index d4dc82a56..89b230d85 100644
--- a/app/models/chouette/vehicle_journey.rb
+++ b/app/models/chouette/vehicle_journey.rb
@@ -243,6 +243,14 @@ module Chouette
end
end
+ def custom_fields
+ CustomField.where(resource_type: self.class.name.split("::").last)
+ end
+
+ def custom_field_value key
+ custom_field_values[key.to_s]
+ end
+
def self.matrix(vehicle_journeys)
Hash[*VehicleJourneyAtStop.where(vehicle_journey_id: vehicle_journeys.pluck(:id)).map do |vjas|
[ "#{vjas.vehicle_journey_id}-#{vjas.stop_point_id}", vjas]