aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorXinhui2016-10-20 11:59:31 +0200
committerXinhui2016-10-20 11:59:31 +0200
commit14c0e5d6960f69bfc228c7390b3af9eb674724f6 (patch)
tree2a21af7efaf6e9e66404f388a5cd690be4c62d61 /app
parent3416c562e3b139594b7cd267cf32f03b3982fcc0 (diff)
downloadchouette-core-14c0e5d6960f69bfc228c7390b3af9eb674724f6.tar.bz2
Set referential_metadata periodes as array + templating form
Refs #1782
Diffstat (limited to 'app')
-rw-r--r--app/controllers/referentials_controller.rb5
-rw-r--r--app/models/chouette/line.rb2
-rw-r--r--app/models/referential.rb10
-rw-r--r--app/views/referentials/_form.html.slim7
4 files changed, 17 insertions, 7 deletions
diff --git a/app/controllers/referentials_controller.rb b/app/controllers/referentials_controller.rb
index 28a95c784..4ffb6ad65 100644
--- a/app/controllers/referentials_controller.rb
+++ b/app/controllers/referentials_controller.rb
@@ -73,8 +73,9 @@ class ReferentialsController < BreadcrumbController
:organisation_id,
:projection_type,
:data_format,
- :archived_at
+ :archived_at,
+ referential_metadata_attributes: [:referential_source_id, :line_ids => []]
)
end
-end \ No newline at end of file
+end
diff --git a/app/models/chouette/line.rb b/app/models/chouette/line.rb
index f2e3a2b08..c3a867caa 100644
--- a/app/models/chouette/line.rb
+++ b/app/models/chouette/line.rb
@@ -18,8 +18,6 @@ class Chouette::Line < Chouette::ActiveRecord
has_many :footnotes, :inverse_of => :line, :validate => :true, :dependent => :destroy
accepts_nested_attributes_for :footnotes, :reject_if => :all_blank, :allow_destroy => true
- belongs_to_array_in_many :referential_metadatas
-
attr_reader :group_of_line_tokens
attr_accessor :transport_mode
diff --git a/app/models/referential.rb b/app/models/referential.rb
index f8f8961ff..9612b1022 100644
--- a/app/models/referential.rb
+++ b/app/models/referential.rb
@@ -28,11 +28,14 @@ class Referential < ActiveRecord::Base
belongs_to :line_referential
validates_presence_of :line_referential
+
has_many :lines, through: :line_referential
has_many :companies, through: :line_referential
has_many :group_of_lines, through: :line_referential
has_many :networks, through: :line_referential
- has_many :referential_metadatas
+
+ has_one :referential_metadata
+ accepts_nested_attributes_for :referential_metadata
belongs_to :stop_area_referential
validates_presence_of :stop_area_referential
@@ -145,6 +148,11 @@ class Referential < ActiveRecord::Base
projection_type || ""
end
+ after_create :autocreate_referential_metadata
+ def autocreate_referential_metadata
+ self.create_referential_metadata if workbench
+ end
+
before_create :create_schema
def create_schema
Apartment::Tenant.create slug
diff --git a/app/views/referentials/_form.html.slim b/app/views/referentials/_form.html.slim
index 985fee4b4..dd426f426 100644
--- a/app/views/referentials/_form.html.slim
+++ b/app/views/referentials/_form.html.slim
@@ -1,7 +1,7 @@
= semantic_form_for @referential, class: 'form-horizontal' do |form|
= form.inputs do
= form.input :name
-
+
- if @referential.new_record?
= form.input :slug, :input_html => { title: t("formtastic.titles.referential.slug") }
- else
@@ -16,6 +16,9 @@
= form.input :lower_corner, input_html: { title: t("formtastic.titles.referential.lower_corner") }
= form.input :data_format, label: true, include_blank: false
+ = form.inputs for: [:referential_metadata, @referential.referential_metadata] do |meta|
+ = meta.inputs :referential_source
+
= form.actions do
= form.action :submit, as: :button
- = form.action :cancel, as: :link \ No newline at end of file
+ = form.action :cancel, as: :link