ActiveAdmin.register Nominee do
  config.sort_order = 'contest_asc category_asc'
  filter :associated_contests
  filter :category
  filter :is_winner?

  index do
    selectable_column
    column :contest, sortable: true
    column :category, sortable: true
    column :name
    column :film
    column :extra_info
    column :is_winner?
  end

  batch_action :mark_winner do |ids|
    Nominee.find(ids).each do |n|
      n.update(is_winner?: true)
    end
    redirect_to collection_path, alert: 'marked winners'
  end

  batch_action :mark_not_winner do |ids|
    Nominee.find(ids).each do |n|
      n.update(is_winner?: false)
    end
    redirect_to collection_path, alert: 'marked winners'
  end

# See permitted parameters documentation:
# https://github.com/activeadmin/activeadmin/blob/master/docs/2-resource-customization.md#setting-up-strong-parameters
#
# permit_params :list, :of, :attributes, :on, :model
#
# or
#
# permit_params do
#   permitted = [:permitted, :attributes]
#   permitted << :other if params[:action] == 'create' && current_user.admin?
#   permitted
# end


end
