Files
codeocean/app/policies/codeharbor_link_policy.rb
Sebastian Serth 293bcccc80 Introduce new enabled option for CodeHarbor
* Fix tests to ensure they work independent of config option
2021-02-16 14:29:54 +01:00

40 lines
506 B
Ruby

class CodeharborLinkPolicy < ApplicationPolicy
def index?
false
end
def show?
false
end
def new?
enabled? && (teacher? || admin?)
end
def create?
enabled? && (teacher? || admin?)
end
def edit?
enabled? && owner?
end
def update?
enabled? && owner?
end
def destroy?
enabled? && owner?
end
def enabled?
CodeOcean::Config.new(:code_ocean).read[:codeharbor][:enabled]
end
private
def owner?
@record.reload.user == @user
end
end