This repository has been archived by the owner on Sep 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#45] added a bunch of roles for exec positions, moved from applicati…
…on.yml to role.rb; misc other changes
- Loading branch information
Patrick Stoica
committed
Apr 18, 2014
1 parent
f0a0d75
commit 20aabb1
Showing
6 changed files
with
86 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,5 +12,4 @@ ADMIN_LAST_NAME: Burdell | |
ADMIN_USERNAME: gpb | ||
ADMIN_EMAIL: [email protected] | ||
ADMIN_PASSWORD: password | ||
ROLES: exec,contest_director,psa_director | ||
USE_LDAP: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,17 @@ | ||
class AddExecStaffToUser < ActiveRecord::Migration | ||
def change | ||
def up | ||
add_column :users, :exec_staff, :boolean | ||
|
||
User.with_role(:exec).each do |user| | ||
user.remove_role :exec | ||
user.exec_staff = true | ||
user.save | ||
end | ||
|
||
Role.find_by(name: "exec").destroy | ||
end | ||
|
||
def down | ||
remove_column :users, :exec_staff | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,20 +8,24 @@ | |
# Environment variables (ENV['...']) are set in the file config/application.yml. | ||
# See http://railsapps.github.io/rails-environment-variables.html | ||
puts 'ROLES' | ||
ENV['ROLES'].split(',').each do |role| | ||
Role.find_or_create_by_name(role) | ||
puts 'role: ' << role | ||
Role::DEFAULT_ROLES.each do |role| | ||
r = Role.find_or_initialize_by_name(role[:name]) | ||
r.full_name = role[:full_name] | ||
r.save | ||
|
||
puts "role: #{r.full_name}" | ||
end | ||
|
||
puts 'DEFAULT USERS' | ||
user = User.find_by(email: '[email protected]') || User.new | ||
user.email = '[email protected]' | ||
user.first_name = 'George' | ||
user.last_name = 'Burdell' | ||
user.username = 'gpb' | ||
user.password = 'password' | ||
user.password_confirmation = 'password' | ||
user.admin = true | ||
user.save | ||
unless Rails.env.production? | ||
puts 'DEFAULT USERS' | ||
user = User.find_or_initialize_by_email('[email protected]') | ||
user.first_name = 'George' | ||
user.last_name = 'Burdell' | ||
user.username = 'gpb' | ||
user.password = 'password' | ||
user.password_confirmation = 'password' | ||
user.admin = true | ||
user.save | ||
|
||
puts 'user: ' << user.name | ||
puts 'user: ' << user.name | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters