diff options
| author | Guillaume | 2017-11-13 11:59:46 +0100 | 
|---|---|---|
| committer | Guillaume | 2017-11-13 12:00:35 +0100 | 
| commit | 834a486b3c0cd9d2dbdae3588d9464f2f9d7287e (patch) | |
| tree | b1c8e84111dddf91f38917d5619d4f157660ae1c | |
| parent | 3b3d3252aa514fbd5b2c12a6cc0a2825d9d8b12e (diff) | |
| download | chouette-core-834a486b3c0cd9d2dbdae3588d9464f2f9d7287e.tar.bz2 | |
add seedbank gems for spliting seeds, update objectid_format in seeds files, add objectid_format to stif initializers
| -rw-r--r-- | Gemfile | 3 | ||||
| -rw-r--r-- | Gemfile.lock | 2 | ||||
| -rw-r--r-- | config/initializers/stif.rb | 1 | ||||
| -rw-r--r-- | db/seeds/chouette.seeds.rb (renamed from db/seeds.rb) | 4 | ||||
| -rw-r--r-- | db/seeds/stif.seeds.rb | 43 | 
5 files changed, 53 insertions, 0 deletions
| @@ -35,6 +35,9 @@ gem 'has_array_of', af83: 'has_array_of'  gem 'rails-observers' +# Use SeedBank for spliting seeds +gem 'seedbank' +  # Use ActiveModel has_secure_password  # gem 'bcrypt', '~> 3.1.7' diff --git a/Gemfile.lock b/Gemfile.lock index 48a8b638a..9262eeb74 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -458,6 +458,7 @@ GEM      sdoc (0.4.2)        json (~> 1.7, >= 1.7.7)        rdoc (~> 4.0) +    seedbank (0.4.0)      select2-rails (4.0.3)        thor (~> 0.14)      sequel (4.47.0) @@ -652,6 +653,7 @@ DEPENDENCIES    sass-rails (~> 4.0.3)    sawyer (~> 0.6.0)    sdoc (~> 0.4.0) +  seedbank    select2-rails (~> 4.0, >= 4.0.3)    sequel    shoulda-matchers (~> 3.1) diff --git a/config/initializers/stif.rb b/config/initializers/stif.rb index f20429575..ca08a7756 100644 --- a/config/initializers/stif.rb +++ b/config/initializers/stif.rb @@ -6,6 +6,7 @@ Rails.application.config.to_prepare do      organisation.workbenches.find_or_create_by(name: "Gestion de l'offre") do |workbench|        workbench.line_referential      = line_referential        workbench.stop_area_referential = stop_area_referential +      workbench.objectid_format = Workbench.objectid_format.stif_netex        Rails.logger.debug "Create Workbench for #{organisation.name}"      end diff --git a/db/seeds.rb b/db/seeds/chouette.seeds.rb index d31a35cfc..75208f0fe 100644 --- a/db/seeds.rb +++ b/db/seeds/chouette.seeds.rb @@ -36,3 +36,7 @@ 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) } + +# Set type of objectid_format +line_referential.update objectid_format: "netex" +stop_area_referential.update objectid_format: "netex" diff --git a/db/seeds/stif.seeds.rb b/db/seeds/stif.seeds.rb new file mode 100644 index 000000000..8674958ab --- /dev/null +++ b/db/seeds/stif.seeds.rb @@ -0,0 +1,43 @@ +# 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) } + +# Set type of objectid_format +line_referential.update objectid_format: "stif_netex" +stop_area_referential.update objectid_format: "stif_netex" + | 
