2015-03-12 22:43:13 +00:00
|
|
|
class GroupPolicy < ApplicationPolicy
|
|
|
|
|
2015-03-17 22:33:16 +00:00
|
|
|
def index?
|
|
|
|
!user.guest?
|
|
|
|
end
|
2015-04-10 23:22:46 +01:00
|
|
|
alias_method :create?, :index?
|
|
|
|
alias_method :remove_user?, :index?
|
2015-03-17 22:33:16 +00:00
|
|
|
|
|
|
|
def show?
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
def reader?
|
2015-04-10 23:22:46 +01:00
|
|
|
!user.guest? && ( is_admin? || local_reader? )
|
2015-03-17 22:33:16 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def write?
|
2015-04-10 23:22:46 +01:00
|
|
|
!user.guest? && ( is_admin? || owner? || local_writer? )
|
2015-03-17 22:33:16 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def update?
|
2015-04-10 23:22:46 +01:00
|
|
|
!user.guest? && ( is_admin? || owner? || local_admin? )
|
2015-03-17 22:33:16 +00:00
|
|
|
end
|
2015-03-19 23:31:41 +00:00
|
|
|
alias_method :add_member?, :update?
|
2015-03-18 22:02:38 +00:00
|
|
|
alias_method :manage_members?, :update?
|
|
|
|
alias_method :members?, :update?
|
|
|
|
alias_method :remove_member?, :update?
|
|
|
|
alias_method :remove_members?, :update?
|
|
|
|
alias_method :update_member?, :update?
|
|
|
|
|
|
|
|
def destroy?
|
2015-04-10 23:22:46 +01:00
|
|
|
!user.guest? && ( is_admin? || owner? )
|
2015-03-18 22:02:38 +00:00
|
|
|
end
|
2015-03-17 22:33:16 +00:00
|
|
|
|
2015-04-28 23:28:36 +01:00
|
|
|
# Public: Get list of parameters that the user is allowed to alter.
|
|
|
|
#
|
|
|
|
# Returns Array
|
|
|
|
def permitted_attributes
|
|
|
|
%i(uname description delete_avatar default_branch)
|
|
|
|
end
|
|
|
|
|
2015-04-01 22:34:14 +01:00
|
|
|
class Scope < Scope
|
|
|
|
def show
|
|
|
|
scope
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-03-12 22:43:13 +00:00
|
|
|
end
|