clarion/app/controllers/public/volunteers_controller.rb

47 lines
1.4 KiB
Ruby
Raw Normal View History

2015-10-21 23:13:39 +03:00
module Public
class VolunteersController < Public::ApplicationController
2024-04-18 21:11:08 +03:00
before_action :check_honey_pot, only: [:create, :edit]
2015-10-21 23:13:39 +03:00
def new
@volunteer = current_conference.volunteers.build
end
def edit
@volunteer = current_conference.volunteers.find_by! unique_id: params[:id]
end
def create
@volunteer = current_conference.volunteers.build volunteer_params
if @volunteer.save
2019-04-28 21:10:54 +03:00
flash[:notice] = I18n.t("views.volunteers.successful_application")
2015-10-21 23:13:39 +03:00
redirect_to edit_volunteer_path(@volunteer.unique_id)
else
render :new, status: :unprocessable_entity
end
end
def update
@volunteer = current_conference.volunteers.find_by! unique_id: params[:id]
if @volunteer.update volunteer_params
2019-04-28 21:10:54 +03:00
flash[:notice] = I18n.t("views.volunteers.successful_application_edit")
2015-10-21 23:13:39 +03:00
redirect_to edit_volunteer_path(@volunteer.unique_id)
else
render :edit, status: :unprocessable_entity
end
end
private
2024-04-18 21:11:08 +03:00
def check_honey_pot
head :unauthorized unless params.dig(:volunteer_ht, :full_name).blank?
end
2015-10-21 23:13:39 +03:00
def volunteer_params
params.require(:volunteer).permit(
:name, :picture, :email, :phone, :tshirt_size, :tshirt_cut,
:food_preferences, :previous_experience, :notes, :language,
:volunteer_team_id
2015-10-21 23:13:39 +03:00
)
end
end
end