diff options
| author | cedricnjanga | 2017-11-27 16:30:48 +0100 |
|---|---|---|
| committer | cedricnjanga | 2017-11-27 16:30:48 +0100 |
| commit | 6bd0791839353750511ce4a49e6b75a462dfec51 (patch) | |
| tree | b5106a746950541d4ee864c8369d0eadc6ab8638 /db | |
| parent | d5db245d67ba14351f09c707b566671e1bd04541 (diff) | |
| parent | ff28f0371280b8258921f8204e7af9c7edb56413 (diff) | |
| download | chouette-core-6bd0791839353750511ce4a49e6b75a462dfec51.tar.bz2 | |
Merge branch 'master' of github.com:af83/stif-boiv
Diffstat (limited to 'db')
| -rw-r--r-- | db/migrate/20171001100320_add_custom_view_to_organisations.rb | 5 | ||||
| -rw-r--r-- | db/migrate/20171001100642_stif_define_custom_view_for_organisations.rb | 5 | ||||
| -rw-r--r-- | db/schema.rb | 1 | ||||
| -rw-r--r-- | db/seeds/chouette.seeds.rb | 40 | ||||
| -rw-r--r-- | db/seeds/stif.rb | 38 |
5 files changed, 53 insertions, 36 deletions
diff --git a/db/migrate/20171001100320_add_custom_view_to_organisations.rb b/db/migrate/20171001100320_add_custom_view_to_organisations.rb new file mode 100644 index 000000000..bd8da50fc --- /dev/null +++ b/db/migrate/20171001100320_add_custom_view_to_organisations.rb @@ -0,0 +1,5 @@ +class AddCustomViewToOrganisations < ActiveRecord::Migration + def change + add_column :organisations, :custom_view, :string + end +end diff --git a/db/migrate/20171001100642_stif_define_custom_view_for_organisations.rb b/db/migrate/20171001100642_stif_define_custom_view_for_organisations.rb new file mode 100644 index 000000000..304c90a1a --- /dev/null +++ b/db/migrate/20171001100642_stif_define_custom_view_for_organisations.rb @@ -0,0 +1,5 @@ +class StifDefineCustomViewForOrganisations < ActiveRecord::Migration + def change + Organisation.update_all custom_view: "stif" + end +end diff --git a/db/schema.rb b/db/schema.rb index 58521fc40..349d8e5eb 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -559,6 +559,7 @@ ActiveRecord::Schema.define(version: 20171123110204) do t.string "code" t.datetime "synced_at" t.hstore "sso_attributes" + t.string "custom_view" end add_index "organisations", ["code"], name: "index_organisations_on_code", unique: true, using: :btree diff --git a/db/seeds/chouette.seeds.rb b/db/seeds/chouette.seeds.rb index 6adafa3e9..1cbdb584d 100644 --- a/db/seeds/chouette.seeds.rb +++ b/db/seeds/chouette.seeds.rb @@ -1,38 +1,6 @@ -# coding: utf-8 -# This file should contain all the record creation needed to seed the database with its default values. -# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). +path = File.join(File.expand_path('../seeds', __FILE__), "*.rb") -stop_area_referential = StopAreaReferential.find_or_create_by!(name: "Reflex", objectid_format: "netex") -line_referential = LineReferential.find_or_create_by!(name: "CodifLigne", objectid_format: "netex") - -# Organisations -stif = Organisation.find_or_create_by!(code: "STIF") do |org| - org.name = 'STIF' -end -operator = Organisation.find_or_create_by!(code: 'transporteur-a') do |organisation| - organisation.name = "Transporteur A" +Dir.glob(path).sort.each do |file| + puts "Seed #{file}" + load file end - -# Member -line_referential.add_member stif, owner: true -line_referential.add_member operator - -stop_area_referential.add_member stif, owner: true -stop_area_referential.add_member operator - -# Users -stif.users.find_or_create_by!(username: "admin") do |user| - user.email = 'stif-boiv@af83.com' - user.password = "secret" - user.name = "STIF Administrateur" -end - -operator.users.find_or_create_by!(username: "transporteur") do |user| - user.email = 'stif-boiv+transporteur@af83.com' - user.password = "secret" - user.name = "Martin Lejeune" -end - -# Include all Lines in organisation functional_scope -stif.update sso_attributes: { functional_scope: line_referential.lines.pluck(:objectid) } -operator.update sso_attributes: { functional_scope: line_referential.lines.limit(3).pluck(:objectid) } diff --git a/db/seeds/stif.rb b/db/seeds/stif.rb new file mode 100644 index 000000000..d31a35cfc --- /dev/null +++ b/db/seeds/stif.rb @@ -0,0 +1,38 @@ +# coding: utf-8 +# This file should contain all the record creation needed to seed the database with its default values. +# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). + +stop_area_referential = StopAreaReferential.find_or_create_by!(name: "Reflex") +line_referential = LineReferential.find_or_create_by!(name: "CodifLigne") + +# Organisations +stif = Organisation.find_or_create_by!(code: "STIF") do |org| + org.name = 'STIF' +end +operator = Organisation.find_or_create_by!(code: 'transporteur-a') do |organisation| + organisation.name = "Transporteur A" +end + +# Member +line_referential.add_member stif, owner: true +line_referential.add_member operator + +stop_area_referential.add_member stif, owner: true +stop_area_referential.add_member operator + +# Users +stif.users.find_or_create_by!(username: "admin") do |user| + user.email = 'stif-boiv@af83.com' + user.password = "secret" + user.name = "STIF Administrateur" +end + +operator.users.find_or_create_by!(username: "transporteur") do |user| + user.email = 'stif-boiv+transporteur@af83.com' + user.password = "secret" + user.name = "Martin Lejeune" +end + +# Include all Lines in organisation functional_scope +stif.update sso_attributes: { functional_scope: line_referential.lines.pluck(:objectid) } +operator.update sso_attributes: { functional_scope: line_referential.lines.limit(3).pluck(:objectid) } |
