Enable and fix booth selection back

This commit is contained in:
Bertocq
2017-10-16 19:03:19 +02:00
committed by Javi Martín
parent 77930d3275
commit 80a9ba8aa7
6 changed files with 23 additions and 30 deletions

View File

@@ -27,7 +27,14 @@ class Officing::BaseController < ApplicationController
end
def verify_booth
if current_booth.blank?
return unless current_booth.blank?
booths = todays_booths_for_officer(current_user.poll_officer)
case booths.count
when 0
redirect_to officing_root_path
when 1
session[:booth_id] = booths.first.id
else
redirect_to new_officing_booth_path
end
end
@@ -36,4 +43,8 @@ class Officing::BaseController < ApplicationController
Poll::Booth.where(id: session[:booth_id]).first
end
def todays_booths_for_officer(officer)
officer.officer_assignments.by_date(Date.today).map(&:booth).uniq
end
end