aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/controllers/referentials_controller.rb6
-rw-r--r--app/models/referential.rb17
2 files changed, 10 insertions, 13 deletions
diff --git a/app/controllers/referentials_controller.rb b/app/controllers/referentials_controller.rb
index 3ae59f975..003c85d3a 100644
--- a/app/controllers/referentials_controller.rb
+++ b/app/controllers/referentials_controller.rb
@@ -57,11 +57,7 @@ class ReferentialsController < BreadcrumbController
end
def create_resource(referential)
- if referential.created_from
- referential.clone_association referential.created_from
- else
- referential.organisation = current_organisation
- end
+ referential.organisation = current_organisation unless referential.created_from
super
end
diff --git a/app/models/referential.rb b/app/models/referential.rb
index afadf5edd..1e2c2acc3 100644
--- a/app/models/referential.rb
+++ b/app/models/referential.rb
@@ -128,13 +128,6 @@ class Referential < ActiveRecord::Base
})
end
- def clone_association from
- self.organisation = from.organisation
- self.line_referential = from.line_referential
- self.stop_area_referential = from.stop_area_referential
- self.workbench = from.workbench
- end
-
def self.available_srids
[
[ "RGF 93 Lambert 93 (2154)", 2154 ],
@@ -171,7 +164,8 @@ class Referential < ActiveRecord::Base
projection_type || ""
end
- before_validation :assign_line_and_stop_area_referential, :on => :create, if: :workbench
+ before_validation :assign_line_and_stop_area_referential, :on => :create, if: :workbench, unless: :created_from
+ before_validation :clone_associations, :on => :create, if: :created_from
before_create :create_schema
after_create :create_referential_metadata, if: :workbench, unless: :created_from
@@ -185,6 +179,13 @@ class Referential < ActiveRecord::Base
self.referential_metadatas.create
end
+ def clone_associations
+ self.organisation = created_from.organisation
+ self.line_referential = created_from.line_referential
+ self.stop_area_referential = created_from.stop_area_referential
+ self.workbench = created_from.workbench
+ end
+
def clone_referential_metadatas
self.created_from.referential_metadatas.each do |meta|
self.referential_metadatas << ReferentialMetadata.new_from(meta)