2016-10-09 07:17:34 +03:00
|
|
|
module Management
|
|
|
|
class VolunteersController < ManagementController
|
|
|
|
include CurrentConferenceAssigning
|
|
|
|
|
|
|
|
def index
|
2019-06-16 10:30:08 +03:00
|
|
|
@filters = filter_params || {}
|
2024-04-18 18:57:26 +03:00
|
|
|
@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
|
|
|
|
2019-06-16 10:30:08 +03:00
|
|
|
def filter_params
|
|
|
|
params.fetch(:filters, {}).permit(:volunteer_team_id)
|
|
|
|
end
|
2024-04-18 18:57:26 +03:00
|
|
|
|
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,
|
2024-04-18 18:57:26 +03:00
|
|
|
:volunteer_team_id,
|
|
|
|
additional_volunteer_team_ids: [])
|
2016-10-09 07:17:34 +03:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|