class Ability::OrganisationAbility < Ability::BaseAbility
  def initialize(user)
    super

    if user.is_admin? || user.is_super_admin? || user.machine_token_user? || user.is_tier_3? || user.is_tier_2?
      can :manage, Organisation, :id => user.organisation_id
    elsif user.is_network_admin?
      can [:resources_list], Organisation
    else
      case user.role.try(:name)
      when "monitor_only"
        can [:resources_list], Organisation
      when "network_monitor"
        can [:resources_list], Organisation
      when "tier_1"
        can [:resources_list], Organisation
      when "customer_care_devices_senior_experts"
        can [:resources_list], Organisation
      when "customer_care_devices_experts"
        can [:resources_list], Organisation
      when "customer_care_devices_specialists"
        can [:resources_list], Organisation
      when "vendor_techs"
        can [:resources_list], Organisation
      when "customer_care_general"
        can [:resources_list], Organisation
      when "nw_onboarding_manager"
        can [:resources_list], Organisation
      when "nw_onboarding_techs"
        can [:resources_list], Organisation
      when "network_r&d"
        can [:resources_list], Organisation
      when "organization_monitor"
        can [:resources_list], Organisation
      end
    end
  end
end