class Ability::RadioProfileAbility < 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, RadioProfile, :id => user.radio_profiles.pluck(:id)
      can :manage, ScheduledReport
    else
      case user.role.try(:name)
      when "customer_care_devices_senior_experts"
        can [:read, :create, :update], RadioProfile, :id => user.radio_profiles.pluck(:id)
      when "customer_care_devices_experts"
        can [:read, :create, :update], RadioProfile, :id => user.radio_profiles.pluck(:id)
      when "customer_care_devices_specialists"
        can :read, RadioProfile, :id => user.radio_profiles.pluck(:id)
      when "vendor_techs"
        can :read, RadioProfile, :id => user.radio_profiles.pluck(:id)
      when "nw_onboarding_techs"
        can [:read, :create, :update], RadioProfile, :id => user.radio_profiles.pluck(:id)
      when "customer_care_general"
        can :read, RadioProfile, :id => user.radio_profiles.pluck(:id)
      when "network_r&d"
        can :manage, RadioProfile, :id => user.radio_profiles.pluck(:id)
      when "nw_onboarding_techs"
        can [:read, :create, :update], RadioProfile, :id => user.radio_profiles.pluck(:id)
      end
    end
  end
end