aboutsummaryrefslogtreecommitdiffstats
path: root/app/models/referential.rb
diff options
context:
space:
mode:
authorXinhui2016-10-24 15:24:02 +0200
committerXinhui2016-10-24 15:24:02 +0200
commit45c6a1a9d775546e5543bf7bfb2dffd485bf1f0a (patch)
tree210ab85be8c71940fc65a2264de10e67d3508f71 /app/models/referential.rb
parent2df352163e6987c93273df27e46ad6b07cff8a68 (diff)
downloadchouette-core-45c6a1a9d775546e5543bf7bfb2dffd485bf1f0a.tar.bz2
Referential new_from method
Refs #1863
Diffstat (limited to 'app/models/referential.rb')
-rw-r--r--app/models/referential.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/app/models/referential.rb b/app/models/referential.rb
index 9612b1022..da5791914 100644
--- a/app/models/referential.rb
+++ b/app/models/referential.rb
@@ -29,6 +29,7 @@ class Referential < ActiveRecord::Base
belongs_to :line_referential
validates_presence_of :line_referential
+ belongs_to :created_from, class_name: 'Referential'
has_many :lines, through: :line_referential
has_many :companies, through: :line_referential
has_many :group_of_lines, through: :line_referential
@@ -112,6 +113,28 @@ class Referential < ActiveRecord::Base
self
end
+ def self.new_from from
+ Referential.new({
+ name: "Copie de #{from.name}",
+ slug: "#{from.slug}_clone",
+ prefix: from.prefix,
+ time_zone: from.time_zone,
+ bounds: from.bounds,
+ organisation: from.organisation,
+ line_referential: from.line_referential,
+ stop_area_referential: from.stop_area_referential,
+ workbench: from.workbench,
+ created_from: from,
+ })
+ 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 ],