mirror of https://github.com/fspc/BikeShed-1.git
Jason Denney
12 years ago
23 changed files with 232 additions and 89 deletions
@ -0,0 +1,5 @@ |
|||
//when signed out, or session expires forward to sign in page
|
|||
Ext.Ajax.on('requestexception', function(conn, response, options) { |
|||
if (response.status === 401) { window.location = '/users/sign_in'; } |
|||
}, this); |
|||
|
@ -1,15 +1,46 @@ |
|||
class AppTabPanel < Netzke::Basepack::TabPanel |
|||
component :bikes_border |
|||
component :brands_and_models_border |
|||
component :users_and_profiles_border |
|||
component :logs |
|||
component :bike_log_form |
|||
|
|||
action :sign_out do |c| |
|||
c.icon = :door_out |
|||
c.text = "Sign out #{controller.current_user.email}" if controller.current_user |
|||
end |
|||
|
|||
def configure(c) |
|||
c.active_tab = 3 |
|||
|
|||
#all users |
|||
@@app_tab_panel_items = [ :bikes_border, :brands_and_models_border] |
|||
|
|||
#for users |
|||
if controller.current_user.user? |
|||
@@app_tab_panel_items.concat [:user_profile_border] |
|||
end |
|||
#for admins |
|||
if controller.current_user.admin? |
|||
@@app_tab_panel_items.concat [:users_and_profiles_border, :logs] |
|||
end |
|||
|
|||
@@app_tab_panel_items.each do |item| |
|||
self.class.component item |
|||
end |
|||
|
|||
c.active_tab = 0 |
|||
c.prevent_header = true |
|||
c.items = [ :bikes_border, :brands_and_models_border, :users_and_profiles_border, :logs, :bike_log_form] |
|||
c.tbar = [:sign_out] |
|||
c.items = @@app_tab_panel_items |
|||
super |
|||
end |
|||
|
|||
js_configure do |c| |
|||
c.on_sign_out = <<-JS |
|||
//this will give a 401 error, but made 401 exceptions forward to 'users/sign_in' |
|||
function(){ |
|||
Ext.Ajax.request({ |
|||
url: '/users/sign_out', |
|||
method: 'DELETE' |
|||
}); |
|||
} |
|||
JS |
|||
end |
|||
|
|||
end |
|||
|
|||
|
@ -0,0 +1,21 @@ |
|||
class UserProfileBorder < Netzke::Base |
|||
# Remember regions collapse state and size |
|||
include Netzke::Basepack::ItemPersistence |
|||
component :user_logs |
|||
component :user_profiles |
|||
|
|||
def configure(c) |
|||
super |
|||
c.title = "Profile" |
|||
c.items = [ |
|||
{ netzke_component: :user_logs, region: :center, split: true}, |
|||
{ netzke_component: :user_profiles, region: :south, height: 150, split: true } |
|||
] |
|||
end |
|||
|
|||
js_configure do |c| |
|||
c.layout = :border |
|||
c.border = false |
|||
end |
|||
|
|||
end |
@ -1,3 +1,5 @@ |
|||
class ApplicationController < ActionController::Base |
|||
before_filter :authenticate_user! |
|||
protect_from_forgery |
|||
|
|||
end |
|||
|
@ -0,0 +1,11 @@ |
|||
class UserRole < ActiveRecord::Base |
|||
attr_accessible :role |
|||
|
|||
has_many :users |
|||
|
|||
self.per_page = 15 |
|||
|
|||
def to_s |
|||
self.role |
|||
end |
|||
end |
@ -0,0 +1,8 @@ |
|||
class CreateUserRoles < ActiveRecord::Migration |
|||
def change |
|||
create_table(:user_roles) do |t| |
|||
t.string :role |
|||
t.timestamps |
|||
end |
|||
end |
|||
end |
@ -0,0 +1,9 @@ |
|||
user: |
|||
id: 1 |
|||
role: user |
|||
staff: |
|||
id: 2 |
|||
role: staff |
|||
admin: |
|||
id: 3 |
|||
role: admin |
@ -1,14 +0,0 @@ |
|||
FactoryGirl.define do |
|||
factory :user do |
|||
sequence(:email) { |n| "user_#{n}@example.com" } |
|||
password 'password' |
|||
password_confirmation { password } |
|||
first_name 'Michael' |
|||
last_name 'Scott' |
|||
end |
|||
|
|||
# factory :team do |
|||
# sequence(:name) { |n| "mash it #{n} times" } |
|||
# association :captain, :factory => :user |
|||
# end |
|||
end |
@ -0,0 +1,21 @@ |
|||
FactoryGirl.define do |
|||
factory :user do |
|||
sequence(:email) { |n| "user_#{n}@example.com" } |
|||
password 'password' |
|||
password_confirmation { password } |
|||
first_name 'Michael' |
|||
last_name 'Scott' |
|||
user_role_id 1 |
|||
|
|||
factory :staff do |
|||
first_name 'Staff' |
|||
user_role_id 2 |
|||
end |
|||
|
|||
factory :admin do |
|||
first_name 'Admin' |
|||
user_role_id 3 |
|||
end |
|||
|
|||
end |
|||
end |
Loading…
Reference in new issue