hummingbird-me/kitsu-server

View on GitHub
app/policies/report_policy.rb

Summary

Maintainability
A
0 mins
Test Coverage
B
82%
class ReportPolicy < ApplicationPolicy
  administrated_by :community_mod

  def create?
    return false unless user
    return false if user.has_role?(:banned)
    is_owner?
  end

  def update?
    return false unless user
    return false if user.has_role?(:banned)
    is_owner? || can_administrate?
  end

  def destroy?
    false
  end

  class Scope < Scope
    def resolve
      if can_administrate?
        scope
      else
        scope.where(user: user)
      end
    end
  end
end