Newer
Older
dmpopidor / app / policies / org_policy.rb
@briley briley on 9 Jun 2017 554 bytes added new custom shib ds page
class OrgPolicy < ApplicationPolicy
  attr_reader :user, :org

  def initialize(user, org)
    raise Pundit::NotAuthorizedError, "must be logged in" unless user
    @user = user
    @org = org
  end

  def admin_show?
    user.can_modify_org_details? && (user.org_id == org.id)
  end

  def admin_edit?
    user.can_modify_org_details? && (user.org_id == org.id)
  end

  def admin_update?
    user.can_modify_org_details? && (user.org_id == org.id)
  end

  def parent?
    true
  end

  def children?
    true
  end

  def templates?
    true
  end
end