aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZog2018-04-10 11:34:46 +0200
committerJohan Van Ryseghem2018-04-11 08:42:47 +0200
commitf8a8c9055ea934ac89f91897ce66bec21fa24a64 (patch)
treedf079535c39c83cd89e71846b049530ae7cf8fe4
parent9931afca317d0a69be52d92f582411deb7dc10d2 (diff)
downloadchouette-core-f8a8c9055ea934ac89f91897ce66bec21fa24a64.tar.bz2
Refs #6483; Only use VJ-bound Custom fields
-rw-r--r--app/controllers/vehicle_journeys_controller.rb2
-rw-r--r--app/models/concerns/custom_fields_support.rb4
2 files changed, 5 insertions, 1 deletions
diff --git a/app/controllers/vehicle_journeys_controller.rb b/app/controllers/vehicle_journeys_controller.rb
index 821ea83ff..220f2d29e 100644
--- a/app/controllers/vehicle_journeys_controller.rb
+++ b/app/controllers/vehicle_journeys_controller.rb
@@ -154,7 +154,7 @@ class VehicleJourneysController < ChouetteController
private
def load_custom_fields
- @custom_fields = referential.workgroup&.custom_fields_definitions || {}
+ @custom_fields = Chouette::VehicleJourney.custom_fields_definitions(referential.workgroup)
@extra_headers = Rails.application.config.vehicle_journeys_extra_headers.dup.delete_if do |header|
header[:type] == :custom_field and not @custom_fields.has_key?(header[:name].to_s)
diff --git a/app/models/concerns/custom_fields_support.rb b/app/models/concerns/custom_fields_support.rb
index ba4ea9912..46fc8e73d 100644
--- a/app/models/concerns/custom_fields_support.rb
+++ b/app/models/concerns/custom_fields_support.rb
@@ -11,6 +11,10 @@ module CustomFieldsSupport
fields
end
+ def self.custom_fields_definitions workgroup=:all
+ Hash[*custom_fields(workgroup).map{|cf| [cf.code, cf]}.flatten]
+ end
+
def method_missing method_name, *args
if method_name =~ /custom_field_*/ && method_name.to_sym != :custom_field_values && !@custom_fields_initialized
initialize_custom_fields