mirror of
https://github.com/fspc/BikeShed-1.git
synced 2026-09-16 08:31:36 -04:00
WIP: cancan permissions; it breaks stuff!
This commit is contained in:
@@ -17,7 +17,7 @@ class AppTabPanel < Netzke::Basepack::TabPanel
|
||||
]
|
||||
|
||||
#for users
|
||||
if controller.current_user.user?
|
||||
if controller.current_user.role?(:user)
|
||||
# (had to use hash for borders to get the title to display properly)
|
||||
@@app_tab_panel_items.concat [{ layout: :fit,
|
||||
wrappedComponent: :user_profile_border,
|
||||
@@ -28,7 +28,7 @@ class AppTabPanel < Netzke::Basepack::TabPanel
|
||||
]
|
||||
end
|
||||
#for admins
|
||||
if controller.current_user.admin?
|
||||
if controller.current_user.role?(:admin)
|
||||
# (had to use hash for borders to get the title to display properly)
|
||||
@@app_tab_panel_items.concat [{ layout: :fit,
|
||||
wrappedComponent: :users_and_profiles_border,
|
||||
|
||||
@@ -30,11 +30,12 @@ class BikeLogs < Netzke::Basepack::Grid
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
if controller.current_user.user?
|
||||
c.prohibit_update = true
|
||||
c.prohibit_create = true
|
||||
c.prohibit_delete = true
|
||||
|
||||
#TODO: fix GUI so it actually respects this
|
||||
current_bike = Bike.find_by_id(session[:selected_bike_id])
|
||||
if cannot? :update, current_bike
|
||||
# if you can't update the bike, you can't do anything to the log
|
||||
c.prohibit_update = c.prohibit_create = c.prohibit_delete = true
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
+4
-8
@@ -24,16 +24,12 @@ class User < ActiveRecord::Base
|
||||
"#{first_name} #{last_name}"
|
||||
end
|
||||
|
||||
def user?
|
||||
user_role.to_s == "user"
|
||||
def role
|
||||
user_role.role
|
||||
end
|
||||
|
||||
def staff?
|
||||
user_role.to_s == "staff"
|
||||
end
|
||||
|
||||
def admin?
|
||||
user_role.to_s == "admin"
|
||||
def role?(role)
|
||||
user_role.to_s == role.to_s
|
||||
end
|
||||
|
||||
def total_hours
|
||||
|
||||
Reference in New Issue
Block a user