Sha256: 84844ca439a6219ddedc17534588006d8b7062b75dd13d58fa5a091cc592c65b
Contents?: true
Size: 1.45 KB
Versions: 9
Compression:
Stored size: 1.45 KB
Contents
module EnjuLeaf class Ability include CanCan::Ability def initialize(user, ip_address = nil) case user.try(:role).try(:name) when 'Administrator' can :index, User can [:read, :create, :update], User can :destroy, User do |u| if u != user and u.id != 1 if defined?(EnjuCirculation) true if u.checkouts.not_returned.empty? else true end end end can [:read, :create, :update], UserGroup can :destroy, UserGroup do |user_group| user_group.users.empty? end can :manage, [ UserHasRole ] can :update, [ Role ] if LibraryGroup.site_config.network_access_allowed?(ip_address) can :read, [ Role ] when 'Librarian' can [:read, :create, :update], User can :destroy, User do |u| if u.role.name == 'User' and u != user if defined?(EnjuCirculation) true if u.checkouts.not_returned.empty? else true end end end can :read, [ Role, UserGroup ] when 'User' can :show, User can :update, User do |u| u == user end can :read, [ UserGroup ] else can :read, [ UserGroup ] end end end end
Version data entries
9 entries across 9 versions & 1 rubygems