diff options
| -rw-r--r-- | app/models/chouette/line.rb | 3 | ||||
| -rw-r--r-- | app/views/lines/show.html.slim | 5 | ||||
| -rw-r--r-- | db/migrate/20170203094212_add_secondary_companies_to_lines.rb | 6 | ||||
| -rw-r--r-- | db/schema.rb | 22 |
4 files changed, 16 insertions, 20 deletions
diff --git a/app/models/chouette/line.rb b/app/models/chouette/line.rb index 6c5d8501f..27a37a7f4 100644 --- a/app/models/chouette/line.rb +++ b/app/models/chouette/line.rb @@ -14,6 +14,9 @@ class Chouette::Line < Chouette::ActiveRecord belongs_to :company belongs_to :network + + has_array_of :secondary_companies, class_name: 'Chouette::Company' + has_many :routes, :dependent => :destroy has_many :journey_patterns, :through => :routes has_many :vehicle_journeys, :through => :journey_patterns diff --git a/app/views/lines/show.html.slim b/app/views/lines/show.html.slim index 7aeb78033..a6e29b88b 100644 --- a/app/views/lines/show.html.slim +++ b/app/views/lines/show.html.slim @@ -31,7 +31,10 @@ = t('lines.index.unset') - else = link_to @line.company.name, [@line_referential, @line.company] - + p + label = "#{@line.human_attribute_name(:secondary_companies)} : " + - @line.secondary_companies.each do |company| + = link_to @company.name, [@line_referential, @company] p label = "#{@line.human_attribute_name('number')} : " = @line.number diff --git a/db/migrate/20170203094212_add_secondary_companies_to_lines.rb b/db/migrate/20170203094212_add_secondary_companies_to_lines.rb new file mode 100644 index 000000000..0cb4d6396 --- /dev/null +++ b/db/migrate/20170203094212_add_secondary_companies_to_lines.rb @@ -0,0 +1,6 @@ +class AddSecondaryCompaniesToLines < ActiveRecord::Migration + def change + add_column :lines, :secondary_companies_ids, :integer, array: true + add_index :lines, :secondary_companies_ids, using: :gin + end +end diff --git a/db/schema.rb b/db/schema.rb index 20e716fa2..6beb862fa 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20170127092058) do +ActiveRecord::Schema.define(version: 20170203094212) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -161,22 +161,6 @@ ActiveRecord::Schema.define(version: 20170127092058) do add_index "connection_links", ["objectid"], :name => "connection_links_objectid_key", :unique => true - create_table "delayed_jobs", force: true do |t| - t.integer "priority", default: 0 - t.integer "attempts", default: 0 - t.text "handler" - t.text "last_error" - t.datetime "run_at" - t.datetime "locked_at" - t.datetime "failed_at" - t.string "locked_by" - t.string "queue" - t.datetime "created_at" - t.datetime "updated_at" - end - - add_index "delayed_jobs", ["priority", "run_at"], :name => "delayed_jobs_priority" - create_table "exports", force: true do |t| t.integer "referential_id", limit: 8 t.string "status" @@ -363,11 +347,13 @@ ActiveRecord::Schema.define(version: 20170127092058) do t.boolean "deactivated", default: false t.text "import_xml" t.string "transport_submode" + t.integer "secondary_companies_ids", array: true end add_index "lines", ["line_referential_id"], :name => "index_lines_on_line_referential_id" add_index "lines", ["objectid"], :name => "lines_objectid_key", :unique => true add_index "lines", ["registration_number"], :name => "lines_registration_number_key" + add_index "lines", ["secondary_companies_ids"], :name => "index_lines_on_secondary_companies_ids" create_table "networks", force: true do |t| t.string "objectid", null: false @@ -779,8 +765,6 @@ ActiveRecord::Schema.define(version: 20170127092058) do add_index "workbenches", ["stop_area_referential_id"], :name => "index_workbenches_on_stop_area_referential_id" Foreigner.load - add_foreign_key "access_links", "access_points", name: "aclk_acpt_fkey", dependent: :delete - add_foreign_key "group_of_lines_lines", "group_of_lines", name: "groupofline_group_fkey", dependent: :delete add_foreign_key "journey_frequencies", "timebands", name: "journey_frequencies_timeband_id_fk", dependent: :nullify |
