module Oxen class PrintJobPolicy < AbstractResourcePolicy class Scope < Scope def resolve if current_user.nil? super elsif current_user.admin? scope.all else scope.where(id: current_user.account.id) end end end def new? current_user.admin? end def index? @current_user.admin? || @current_user.account_admin? end def create? @current_user.admin? end def show? @current_user.admin? or @current_user.account==@model end def edit? @current_user.admin? or @current_user.account==@model end def update? @current_user.admin? or @current_user.account==@model end def destroy? @current_user.admin? end def print? @current_user.admin? || @current_user.account_admin? end end end