Sha256: 178eb5f634e4d5d32fd74367f967312ac4fb768adf23028d279a14706fbff93d

Contents?: true

Size: 1.99 KB

Versions: 4

Compression:

Stored size: 1.99 KB

Contents

app_module = Mks::Auth::ApplicationModule.where(code: 'EDM', name: 'Equipment Data Module').first_or_create
equipment_owner = Mks::Auth::UserRole.where(name: 'equipment_owner', application_module_id: app_module.id).first_or_create
equipment_staff = Mks::Auth::UserRole.where(name: 'equipment_staff', application_module_id: app_module.id).first_or_create

menu1 = Mks::Auth::Menu.where(text: 'Equipment Setting', application_module_id: app_module.id).first_or_create
menu2 = Mks::Auth::Menu.where(text: 'Equipment Transaction', application_module_id: app_module.id).first_or_create

Mks::Auth::Menu.where(text: 'Equipment Types', parent_id: menu1.id, location: 'equipment_types',
                      application_module_id: app_module.id).first_or_create
Mks::Auth::Menu.where(text: 'Equipment Categories', parent_id: menu1.id, location: 'equipment_categories',
                      application_module_id: app_module.id).first_or_create
Mks::Auth::Menu.where(text: 'Equipments', parent_id: menu1.id, location: 'equipments',
                      application_module_id: app_module.id).first_or_create
Mks::Auth::Menu.where(text: 'Equipment Items', parent_id: menu2.id, location: 'equipment_items',
                      application_module_id: app_module.id).first_or_create

equipment_owner_menu = equipment_owner.menus.where(application_module_id: app_module.id)
equipment_owner.menus.delete(equipment_owner_menu)
equipment_owner.menus << menu1
equipment_owner.menus << menu1.children

equipment_staff_menu = equipment_staff.menus.where(application_module_id: app_module.id)
equipment_staff.menus.delete(equipment_staff_menu)
equipment_staff.menus << menu2
equipment_staff.menus << menu2.children

u1 = Mks::Auth::User.where(first_name: 'Adey', last_name: 'E.')
if u1.empty?
  u1 = Mks::Auth::User.create(first_name: 'Adey', last_name: 'E.', email: 'adey@gmail.com', active: true,
                              application_modules: [app_module], password: 'adey123')
  u1.roles << equipment_owner
  u1.roles << equipment_staff
end


Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mks_edm-1.0.5 db/seeds.rb
mks_edm-1.0.4 db/seeds.rb
mks_edm-1.0.2 db/seeds.rb
mks_edm-1.0.1 db/seeds.rb