Deleting a booth shift with recounts or partial results.

Show a flash message that it's not possible to delete booth shifts
when they have associated recounts or partial results. Before an
execption was raised.
This commit is contained in:
Julian Herrero
2019-02-06 10:55:43 +01:00
parent e76f483850
commit 5f4a369606
6 changed files with 70 additions and 3 deletions

View File

@@ -26,9 +26,14 @@ class Admin::Poll::ShiftsController < Admin::Poll::BaseController
def destroy
@shift = Poll::Shift.find(params[:id])
@shift.destroy
notice = t("admin.poll_shifts.flash.destroy")
redirect_to new_admin_booth_shift_path(@booth), notice: notice
if @shift.unable_to_destroy?
alert = t("admin.poll_shifts.flash.unable_to_destroy")
redirect_to new_admin_booth_shift_path(@booth), alert: alert
else
@shift.destroy
notice = t("admin.poll_shifts.flash.destroy")
redirect_to new_admin_booth_shift_path(@booth), notice: notice
end
end
def search_officers