mirror of https://github.com/fspc/BikeShed-1.git
jnm
12 years ago
18 changed files with 124 additions and 53 deletions
@ -0,0 +1,21 @@ |
|||
class UserRoleJoins < Netzke::Basepack::Grid |
|||
def configure(c) |
|||
super |
|||
c.model = "UserRoleJoin" |
|||
c.header = false |
|||
c.title = "User Roles" |
|||
c.columns = [ |
|||
{ :name => :user__first_name, :text => "First"}, |
|||
{ :name => :user__last_name, :text => "Last"}, |
|||
{ :name => :role__role, :text => "Role"}, |
|||
:created_at, |
|||
:updated_at, |
|||
:ends ] |
|||
end |
|||
|
|||
#override with nil to remove actions |
|||
def default_bbar |
|||
[ :apply, :add_in_form, :search ] |
|||
end |
|||
|
|||
end |
@ -1,15 +0,0 @@ |
|||
class UserRoles < Netzke::Basepack::Grid |
|||
|
|||
def configure(c) |
|||
super |
|||
c.model = "UserRole" |
|||
c.title = "User Roles" |
|||
c.columns = [ :role, :created_at, :updated_at, :ends ] |
|||
end |
|||
|
|||
#override with nil to remove actions |
|||
def default_bbar |
|||
[ :apply, :add_in_form, :search ] |
|||
end |
|||
|
|||
end |
@ -0,0 +1,16 @@ |
|||
class Role < ActiveRecord::Base |
|||
attr_accessible :role |
|||
|
|||
has_many :user_role_joins |
|||
has_many :users, through: :user_role_joins |
|||
validates_uniqueness_of :role |
|||
|
|||
|
|||
def to_s |
|||
self.role |
|||
end |
|||
|
|||
def ==(other) |
|||
self.role == other.role |
|||
end |
|||
end |
@ -1,11 +0,0 @@ |
|||
class UserRole < ActiveRecord::Base |
|||
attr_accessible :role |
|||
|
|||
belongs_to :user |
|||
|
|||
self.per_page = 15 |
|||
|
|||
def to_s |
|||
self.role |
|||
end |
|||
end |
@ -0,0 +1,13 @@ |
|||
class UserRoleJoin < ActiveRecord::Base |
|||
self.table_name = :user_role_joins |
|||
attr_accessible :role_id, :user_id, :ends |
|||
|
|||
belongs_to :user |
|||
belongs_to :role |
|||
|
|||
validate :role_id, presence: true, numericality: true |
|||
validate :user_id, presence: true, numericality: true |
|||
validates_uniqueness_of :user_id, :scope => :role_id |
|||
|
|||
self.per_page = 15 |
|||
end |
@ -0,0 +1,9 @@ |
|||
class AlterUserRoles < ActiveRecord::Migration |
|||
def change |
|||
rename_table :user_roles, :user_role_joins |
|||
change_table :user_role_joins do |t| |
|||
t.rename :role, :role_id |
|||
t.change :role_id, :integer |
|||
end |
|||
end |
|||
end |
@ -0,0 +1,8 @@ |
|||
class AddRoles < ActiveRecord::Migration |
|||
def change |
|||
create_table(:roles) do |t| |
|||
t.string :role |
|||
t.timestamps |
|||
end |
|||
end |
|||
end |
@ -0,0 +1,5 @@ |
|||
class AlterUser < ActiveRecord::Migration |
|||
def change |
|||
remove_column :users, :user_role_id |
|||
end |
|||
end |
@ -0,0 +1,9 @@ |
|||
user: |
|||
id: 1 |
|||
role: user |
|||
staff: |
|||
id: 2 |
|||
role: staff |
|||
admin: |
|||
id: 3 |
|||
role: admin |
@ -1,5 +1,5 @@ |
|||
FactoryGirl.define do |
|||
factory :user_role do |
|||
factory :role do |
|||
factory :role_staff do |
|||
role 'staff' |
|||
end |
Loading…
Reference in new issue