clarion/app/controllers/management/volunteers_controller.rb

44 lines
1.2 KiB
Ruby
Raw Normal View History

2016-10-09 07:17:34 +03:00
module Management
class VolunteersController < ManagementController
include CurrentConferenceAssigning
def index
@filters = filter_params || {}
@volunteers = VolunteerSearch.new(scope: Volunteer.where(conference: current_conference).eager_load(:volunteer_team), filters: params[:filters]).results
2016-10-09 07:17:34 +03:00
end
def show
@volunteer = current_conference.volunteers.find(params[:id])
end
def edit
@volunteer = current_conference.volunteers.find(params[:id])
end
def update
@volunteer = current_conference.volunteers.find(params[:id])
if @volunteer.update volunteer_params
redirect_to management_conference_volunteer_path(@volunteer, conference_id: current_conference.id)
else
render :edit, status: :unprocessable_entity
end
end
private
2019-04-28 21:10:54 +03:00
def filter_params
params.fetch(:filters, {}).permit(:volunteer_team_id)
end
2016-10-09 07:17:34 +03:00
def volunteer_params
params.require(:volunteer).permit(:name, :picture, :email, :phone,
2019-04-28 21:10:54 +03:00
:tshirt_size, :tshirt_cut,
:food_preferences, :previous_experience,
:notes, :language,
:volunteer_team_id,
additional_volunteer_team_ids: [])
2016-10-09 07:17:34 +03:00
end
end
end