diff options
| -rw-r--r-- | app/models/user.rb | 6 | ||||
| -rw-r--r-- | db/seeds.rb | 18 |
2 files changed, 17 insertions, 7 deletions
diff --git a/app/models/user.rb b/app/models/user.rb index 8e73aa1d5..1230a64a1 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,3 +1,4 @@ +# coding: utf-8 class User < ActiveRecord::Base # Include default devise modules. Others available are: # :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable, :database_authenticatable @@ -32,6 +33,11 @@ class User < ActiveRecord::Base 'vehicle_journeys.create', 'vehicle_journeys.edit', 'vehicle_journeys.destroy', 'time_tables.create', 'time_tables.edit', 'time_tables.destroy', 'footnotes.edit', 'footnotes.create', 'footnotes.destroy', 'routing_constraint_zones.create', 'routing_constraint_zones.edit', 'routing_constraint_zones.destroy', 'referentials.create', 'referentials.edit', 'referentials.destroy'] + mattr_reader :edit_offer_permissions + + def self.all_permissions + edit_offer_permissions + end def cas_extra_attributes=(extra_attributes) extra = extra_attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo} diff --git a/db/seeds.rb b/db/seeds.rb index e3fa4c69d..6e7f59c54 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -7,17 +7,19 @@ # cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }]) # Mayor.create(:name => 'Emanuel', :city => cities.first) -stif = Organisation.find_or_create_by!(name: "STIF") do |org| - org.code = 'STIF' +Organisation.where(code: nil).destroy_all + +stif = Organisation.find_or_create_by!(code: "STIF") do |org| + org.name = 'STIF' end stif.users.find_or_create_by!(username: "admin") do |user| user.email = 'stif-boiv@af83.com' user.password = "secret" user.name = "STIF Administrateur" + user.permissions = User.all_permissions end - operator = Organisation.find_or_create_by!(code: 'transporteur-a') do |organisation| organisation.name = "Transporteur A" end @@ -26,6 +28,7 @@ operator.users.find_or_create_by!(username: "transporteur") do |user| user.email = 'stif-boiv+transporteur@af83.com' user.password = "secret" user.name = "Martin Lejeune" + user.permissions = User.all_permissions end stop_area_referential = StopAreaReferential.find_or_create_by!(name: "Reflex") do |referential| @@ -42,15 +45,16 @@ line_referential = LineReferential.find_or_create_by!(name: "CodifLigne") do |re referential.add_member operator end -LineReferentialSync.find_or_create_by!(line_referential: line_referential) -StopAreaReferentialSync.find_or_create_by!(stop_area_referential: stop_area_referential) - 10.times do |n| - line_referential.lines.find_or_create_by name: "Test #{n}" do |l| + line_referential.lines.find_or_create_by! name: "Test #{n}" do |l| l.objectid = "Chouette:Dummy:Line:00" + n.to_s end 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) } + workbench = Workbench.find_by(name: "Gestion de l'offre") workbench.update_attributes(line_referential: line_referential, stop_area_referential: stop_area_referential) |
