Implement role authorization
This commit is contained in:
parent
6755328c4c
commit
e2fb434dc7
122 changed files with 1386 additions and 751 deletions
|
|
@ -0,0 +1,10 @@
|
|||
class AddDescriptionAndResourceToRoles < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :roles, :description, :string
|
||||
add_reference :roles, :resource, polymorphic: true
|
||||
|
||||
add_index(:roles, :name)
|
||||
add_index(:roles, [:name, :resource_type, :resource_id])
|
||||
add_index(:roles_users, [:user_id, :role_id])
|
||||
end
|
||||
end
|
||||
5
db/migrate/20140718103856_add_is_admin_to_users.rb
Normal file
5
db/migrate/20140718103856_add_is_admin_to_users.rb
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
class AddIsAdminToUsers < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :users, :is_admin, :boolean
|
||||
end
|
||||
end
|
||||
|
|
@ -363,15 +363,23 @@ ActiveRecord::Schema.define(version: 20140801170430) do
|
|||
|
||||
create_table "roles", force: true do |t|
|
||||
t.string "name"
|
||||
t.string "description"
|
||||
t.integer "resource_id"
|
||||
t.string "resource_type"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
end
|
||||
|
||||
add_index "roles", ["name", "resource_type", "resource_id"], name: "index_roles_on_name_and_resource_type_and_resource_id"
|
||||
add_index "roles", ["name"], name: "index_roles_on_name"
|
||||
|
||||
create_table "roles_users", id: false, force: true do |t|
|
||||
t.integer "role_id"
|
||||
t.integer "user_id"
|
||||
end
|
||||
|
||||
add_index "roles_users", ["user_id", "role_id"], name: "index_roles_users_on_user_id_and_role_id"
|
||||
|
||||
create_table "rooms", force: true do |t|
|
||||
t.string "guid", null: false
|
||||
t.integer "conference_id"
|
||||
|
|
@ -484,6 +492,7 @@ ActiveRecord::Schema.define(version: 20140801170430) do
|
|||
t.string "tshirt"
|
||||
t.string "languages"
|
||||
t.text "volunteer_experience"
|
||||
t.boolean "is_admin"
|
||||
end
|
||||
|
||||
add_index "users", ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true
|
||||
|
|
|
|||
18
db/seeds.rb
18
db/seeds.rb
|
|
@ -5,18 +5,18 @@
|
|||
#
|
||||
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
|
||||
# Mayor.create(name: 'Emanuel', city: cities.first)
|
||||
Role.create(name: "Participant")
|
||||
Role.create(name: "Organizer")
|
||||
Role.create(name: "Admin")
|
||||
|
||||
qtype_yesno = QuestionType.create(title: "Yes/No")
|
||||
QuestionType.create(title: "Single Choice")
|
||||
QuestionType.create(title: "Multiple Choice")
|
||||
# Questions
|
||||
qtype_yesno = QuestionType.create(title: 'Yes/No')
|
||||
qtype_single = QuestionType.create(title: 'Single Choice')
|
||||
qtype_multiple = QuestionType.create(title: 'Multiple Choice')
|
||||
|
||||
answer_yes = Answer.create(title: "Yes")
|
||||
answer_no = Answer.create(title: "No")
|
||||
answer_yes = Answer.create(title: 'Yes')
|
||||
answer_no = Answer.create(title: 'No')
|
||||
|
||||
questions_yes_no = ["Do you need handicapped access to the venue?", "Are you attending with partner?", "Will you attend the social event(s)?", "Will you stay at suggested hotel?"]
|
||||
questions_yes_no = ['Do you need handicapped access to the venue?',
|
||||
'Are you attending with partner?', 'Will you attend the social event(s)?',
|
||||
'Will you stay at suggested hotel?']
|
||||
|
||||
questions_yes_no.each do |i|
|
||||
q = Question.create(title: i, question_type_id: qtype_yesno.id, global: true)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue