diff options
| author | Robert | 2017-12-05 11:37:25 +0100 | 
|---|---|---|
| committer | Robert | 2017-12-05 12:19:42 +0100 | 
| commit | 642d2bd3a46a4b459acf18748dbfebf0cb6ca7df (patch) | |
| tree | 773a01b7a4dc86a5dabfab98f6f44bdc9f949a50 /app/models/referential.rb | |
| parent | 089c6935ca0e036de484834381e5beda7545d499 (diff) | |
| download | chouette-core-642d2bd3a46a4b459acf18748dbfebf0cb6ca7df.tar.bz2 | |
Refs: #5179@1.25h; Referential Creation Enforces objectid_format from associated Workbench
  - changed ObjectIdFormatterSupport as requested
  - respeced all defined cases
  - implemented respec
Missing:
  What to do in `define_default_attributes` if ref has no workbench and no `objectid_format`?
Diffstat (limited to 'app/models/referential.rb')
| -rw-r--r-- | app/models/referential.rb | 6 | 
1 files changed, 4 insertions, 2 deletions
| diff --git a/app/models/referential.rb b/app/models/referential.rb index 233a9f24a..e8fb2888e 100644 --- a/app/models/referential.rb +++ b/app/models/referential.rb @@ -127,10 +127,11 @@ class Referential < ActiveRecord::Base      Chouette::RoutingConstraintZone.all    end -  after_initialize :define_default_attributes +  before_validation :define_default_attributes    def define_default_attributes      self.time_zone ||= Time.zone.name +    self.objectid_format ||= workbench.try(:objectid_format) || ObjectidFormatterSupport.legal_formats.first    end    def switch @@ -140,7 +141,7 @@ class Referential < ActiveRecord::Base    end    def self.new_from(from, functional_scope) -e    Referential.new( +     Referential.new(        name: I18n.t("activerecord.copy", name: from.name),        slug: "#{from.slug}_clone",        prefix: from.prefix, @@ -149,6 +150,7 @@ e    Referential.new(        line_referential: from.line_referential,        stop_area_referential: from.stop_area_referential,        created_from: from, +      objectid_format: from.objectid_format,        metadatas: from.metadatas.map { |m| ReferentialMetadata.new_from(m, functional_scope) }      )    end | 
