diff options
| author | Luc Donnet | 2018-04-22 16:12:37 +0200 |
|---|---|---|
| committer | Luc Donnet | 2018-04-22 21:18:41 +0200 |
| commit | c93e050debe52243a927b491aa1ce7c93c8dd03b (patch) | |
| tree | 25e3525c4fa73699fabfa92f22fcbca7d69ac853 | |
| parent | 2fdcaca3a0302d35aa007c3dd309fb42a3c7e536 (diff) | |
| download | chouette-core-c93e050debe52243a927b491aa1ce7c93c8dd03b.tar.bz2 | |
Fix netex import launch because referential is created after the netex import and java call Refs #6645 @1
| -rw-r--r-- | app/controllers/api/v1/netex_imports_controller.rb | 3 | ||||
| -rw-r--r-- | app/models/import/netex.rb | 7 |
2 files changed, 5 insertions, 5 deletions
diff --git a/app/controllers/api/v1/netex_imports_controller.rb b/app/controllers/api/v1/netex_imports_controller.rb index 186ddc35c..2c9caf8fb 100644 --- a/app/controllers/api/v1/netex_imports_controller.rb +++ b/app/controllers/api/v1/netex_imports_controller.rb @@ -31,8 +31,7 @@ module Api def create_netex_import attributes = netex_import_params.merge creator: "Webservice" @netex_import = Import::Netex.new attributes - @netex_import.save! - @netex_import.create_referential! + @netex_import.create_with_referential! rescue ActiveRecord::RecordInvalid render json: {errors: @netex_import.errors}, status: 406 finish_action! diff --git a/app/models/import/netex.rb b/app/models/import/netex.rb index 93604c5f9..7b15859fa 100644 --- a/app/models/import/netex.rb +++ b/app/models/import/netex.rb @@ -10,7 +10,7 @@ class Import::Netex < Import::Base validates_presence_of :parent - def create_referential! + def create_with_referential! self.referential = Referential.new( name: self.name, @@ -19,15 +19,16 @@ class Import::Netex < Import::Base metadatas: [referential_metadata] ) self.referential.save - unless self.referential.valid? + if self.referential.invalid? Rails.logger.info "Can't create referential for import #{self.id}: #{referential.inspect} #{referential.metadatas.inspect} #{referential.errors.messages}" if referential.metadatas.all?{|m| m.line_ids.empty?} parent.messages.create criticity: :error, message_key: "referential_creation_missing_lines", message_attributes: {referential_name: referential.name} else parent.messages.create criticity: :error, message_key: "referential_creation", message_attributes: {referential_name: referential.name} end + else + save! end - save! end private |
