mirror of
https://github.com/fspc/BikeShed-1.git
synced 2025-02-28 00:33:23 -05:00
WIP adding user roles view; adding end datetime to user roles
This commit is contained in:
parent
ac9e5718c7
commit
a3fcdec10c
@ -36,7 +36,8 @@ class AppTabPanel < Netzke::Basepack::TabPanel
|
||||
{ layout: :fit,
|
||||
wrappedComponent: :transactions_border,
|
||||
title: "Transactions"},
|
||||
:logs]
|
||||
:logs,
|
||||
:user_roles]
|
||||
end
|
||||
|
||||
@@app_tab_panel_items.each do |item|
|
||||
|
15
app/components/user_roles.rb
Normal file
15
app/components/user_roles.rb
Normal file
@ -0,0 +1,15 @@
|
||||
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
|
@ -14,7 +14,7 @@ class User < ActiveRecord::Base
|
||||
has_many :user_profiles
|
||||
accepts_nested_attributes_for :user_profiles, allow_destroy: false
|
||||
|
||||
belongs_to :user_role
|
||||
has_one :user_role
|
||||
belongs_to :bike
|
||||
|
||||
validates :first_name, :presence => true
|
||||
@ -24,6 +24,10 @@ class User < ActiveRecord::Base
|
||||
"#{first_name} #{last_name}"
|
||||
end
|
||||
|
||||
def full_name
|
||||
to_s
|
||||
end
|
||||
|
||||
def role
|
||||
user_role.role
|
||||
end
|
||||
|
@ -1,7 +1,7 @@
|
||||
class UserRole < ActiveRecord::Base
|
||||
attr_accessible :role
|
||||
|
||||
has_many :users
|
||||
belongs_to :user
|
||||
|
||||
self.per_page = 15
|
||||
|
||||
|
7
db/migrate/20130419010051_add_ends_to_user_roles.rb
Normal file
7
db/migrate/20130419010051_add_ends_to_user_roles.rb
Normal file
@ -0,0 +1,7 @@
|
||||
class AddEndsToUserRoles < ActiveRecord::Migration
|
||||
def change
|
||||
add_column(:user_roles, :ends, :timestamp)
|
||||
add_column(:user_roles, :user_id, :integer)
|
||||
remove_column(:users, :role_id)
|
||||
end
|
||||
end
|
@ -11,7 +11,7 @@
|
||||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20130405012238) do
|
||||
ActiveRecord::Schema.define(:version => 20130419010051) do
|
||||
|
||||
create_table "bike_actions", :force => true do |t|
|
||||
t.string "action", :limit => 128, :null => false
|
||||
@ -152,6 +152,8 @@ ActiveRecord::Schema.define(:version => 20130405012238) do
|
||||
t.string "role"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.datetime "ends"
|
||||
t.integer "user_id"
|
||||
end
|
||||
|
||||
create_table "users", :force => true do |t|
|
||||
|
@ -1,9 +0,0 @@
|
||||
user:
|
||||
id: 1
|
||||
role: user
|
||||
staff:
|
||||
id: 2
|
||||
role: staff
|
||||
admin:
|
||||
id: 3
|
||||
role: admin
|
@ -21,10 +21,11 @@ end
|
||||
if Rails.env.development?
|
||||
|
||||
#create default admin user
|
||||
if User.all.empty?
|
||||
if UserRole.all.empty? and User.all.empty?
|
||||
FactoryGirl.create(:user)
|
||||
FactoryGirl.create(:staff)
|
||||
FactoryGirl.create(:admin)
|
||||
FactoryGirl.create(:bike_admin)
|
||||
FactoryGirl.create(:user_profile)
|
||||
end
|
||||
|
||||
|
19
spec/factories/user_roles.rb
Normal file
19
spec/factories/user_roles.rb
Normal file
@ -0,0 +1,19 @@
|
||||
FactoryGirl.define do
|
||||
factory :user_role do
|
||||
factory :role_staff do
|
||||
role 'staff'
|
||||
end
|
||||
|
||||
factory :role_admin do
|
||||
role 'admin'
|
||||
end
|
||||
|
||||
factory :role_bike_admin do
|
||||
role 'bike_admin'
|
||||
end
|
||||
|
||||
factory :role_user do
|
||||
role 'user'
|
||||
end
|
||||
end
|
||||
end
|
@ -5,17 +5,22 @@ FactoryGirl.define do
|
||||
password_confirmation { password }
|
||||
first_name 'Michael'
|
||||
last_name 'Scott'
|
||||
user_role_id 1
|
||||
sequence(:bike_id) { |n| n }
|
||||
association :user_role, factory: :role_user
|
||||
|
||||
factory :staff do
|
||||
first_name 'Staff'
|
||||
user_role_id 2
|
||||
association :user_role, factory: :role_staff
|
||||
end
|
||||
|
||||
factory :admin do
|
||||
first_name 'Admin'
|
||||
user_role_id 3
|
||||
association :user_role, factory: :role_admin
|
||||
end
|
||||
|
||||
factory :bike_admin do
|
||||
first_name 'BikeAdmin'
|
||||
association :user_role, factory: :role_bike_admin
|
||||
end
|
||||
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user