Sha256: ce79e9d9c6cd068d9378b8870440ba61cf46aa6f5067fa2090454bb3c5735749
Contents?: true
Size: 1.9 KB
Versions: 5
Compression:
Stored size: 1.9 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 :manage, [ UserImportFile ] if LibraryGroup.site_config.network_access_allowed?(ip_address) can :update, [ Role ] if LibraryGroup.site_config.network_access_allowed?(ip_address) can :read, [ Role, UserImportResult ] if LibraryGroup.site_config.network_access_allowed?(ip_address) 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 :manage, [ UserImportFile ] if LibraryGroup.site_config.network_access_allowed?(ip_address) can :read, [ Role, UserGroup ] can :read, [ UserImportResult ] if LibraryGroup.site_config.network_access_allowed?(ip_address) 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
5 entries across 5 versions & 1 rubygems