Tidy up homepage and navigation
This commit is contained in:
49
app/policies/dsn_policy.rb
Normal file
49
app/policies/dsn_policy.rb
Normal file
@@ -0,0 +1,49 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class DsnPolicy < ApplicationPolicy
|
||||
def index?
|
||||
current_user.present? && current_user.admin?
|
||||
end
|
||||
|
||||
def show?
|
||||
current_user.present? && current_user.admin?
|
||||
end
|
||||
|
||||
def create?
|
||||
current_user.present? && current_user.admin?
|
||||
end
|
||||
|
||||
def new?
|
||||
create?
|
||||
end
|
||||
|
||||
def update?
|
||||
current_user.present? && current_user.admin?
|
||||
end
|
||||
|
||||
def edit?
|
||||
update?
|
||||
end
|
||||
|
||||
def destroy?
|
||||
current_user.present? && current_user.admin?
|
||||
end
|
||||
|
||||
def disable?
|
||||
current_user.present? && current_user.admin?
|
||||
end
|
||||
|
||||
def enable?
|
||||
current_user.present? && current_user.admin?
|
||||
end
|
||||
|
||||
class Scope < Scope
|
||||
def resolve
|
||||
if user&.admin?
|
||||
scope.all
|
||||
else
|
||||
scope.none
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user