OpenProject is the leading open source project management software.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
openproject/lib/chili_project/principal_allowance_evaluator/default.rb

31 lines
863 B

class ChiliProject::PrincipalAllowanceEvaluator::Default < ChiliProject::PrincipalAllowanceEvaluator::Base
def granted_for_global?(candidate, action, options)
granted = super
granted || if candidate.is_a?(Member)
candidate.roles.any?{ |r| r.allowed_to?(action) }
elsif candidate.is_a?(Role)
candidate.allowed_to?(action)
end
end
def granted_for_project?(role, action, project, options)
return false unless role.is_a?(Role)
granted = super
granted || (project.is_public? || role.member?) && role.allowed_to?(action)
end
def global_granting_candidates
role = @user.logged? ?
Role.non_member :
Role.anonymous
@user.memberships + [role]
end
def project_granting_candidates(project)
@user.roles_for_project project
end
end