adds booth assignation to admin poll

This commit is contained in:
Juanjo Bazán
2016-12-23 19:05:16 +01:00
parent 89979e549f
commit 8b4f519d71
13 changed files with 207 additions and 12 deletions

View File

@@ -0,0 +1,35 @@
class Admin::Poll::BoothAssignmentsController < Admin::BaseController
before_action :load_booth_assignment, only: :destroy
def create
@booth_assignment = ::Poll::BoothAssignment.new(poll_id: booth_assignment_params[:poll], booth_id: booth_assignment_params[:booth])
if @booth_assignment.save
notice = t("admin.booth_assignments.flash.create")
else
notice = t("admin.booth_assignments.flash.error_create")
end
redirect_to admin_poll_path(@booth_assignment.poll_id, anchor: 'tab-booths'), notice: notice
end
def destroy
if @booth_assignment.destroy
notice = t("admin.booth_assignments.flash.destroy")
else
notice = t("admin.booth_assignments.flash.error_destroy")
end
redirect_to admin_poll_path(@booth_assignment.poll_id, anchor: 'tab-booths'), notice: notice
end
private
def load_booth_assignment
@booth_assignment = ::Poll::BoothAssignment.find_by(poll: params[:poll], booth: params[:booth])
end
def booth_assignment_params
params.permit(:booth, :poll)
end
end