50 lines
1.4 KiB
Ruby
50 lines
1.4 KiB
Ruby
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
|
|
end
|
|
|
|
def show
|
|
@volunteer = current_conference.volunteers.find(params[:id])
|
|
end
|
|
|
|
def edit
|
|
@volunteer = current_conference.volunteers.find(params[:id])
|
|
end
|
|
|
|
def destroy
|
|
@volunteer = current_conference.volunteers.find(params[:id])
|
|
@volunteer.destroy!
|
|
redirect_to management_conference_volunteers_path(conference_id: current_conference.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
|
|
|
|
def filter_params
|
|
params.fetch(:filters, {}).permit(:volunteer_team_id)
|
|
end
|
|
|
|
def volunteer_params
|
|
params.require(:volunteer).permit(:name, :picture, :email, :phone,
|
|
:tshirt_size, :tshirt_cut,
|
|
:food_preferences, :previous_experience,
|
|
:notes, :language,
|
|
:volunteer_team_id,
|
|
additional_volunteer_team_ids: [])
|
|
end
|
|
end
|
|
end
|