Fix Shift date ranges when poll is on recounting phase

This commit is contained in:
Bertocq
2017-10-23 20:17:42 +02:00
parent f9458b9ef0
commit 3adfbcb830
5 changed files with 10 additions and 4 deletions

View File

@@ -6,6 +6,8 @@ class Admin::Poll::ShiftsController < Admin::Poll::BaseController
def new
load_shifts
@shift = ::Poll::Shift.new
@voting_polls = @booth.polls.current_or_incoming
@recount_polls = @booth.polls.current_or_recounting_or_incoming
end
def create

View File

@@ -1,10 +1,12 @@
module ShiftsHelper
def shift_vote_collection_dates(booth, polls)
return [] if polls.blank?
date_options((start_date(polls)..end_date(polls)), Poll::Shift.tasks[:vote_collection], booth)
end
def shift_recount_scrutiny_dates(booth, polls)
return [] if polls.blank?
dates = polls.map(&:ends_at).map(&:to_date).sort.inject([]) do |total, date|
initial_date = date < Date.current ? Date.current : date
total << (initial_date..date + Poll::RECOUNT_DURATION).to_a

View File

@@ -3,7 +3,7 @@
<fieldset class="fieldset">
<legend>
<%= t("admin.poll_shifts.new.new_shift") %>
<%= t("admin.poll_shifts.new.new_shift") %>
</legend>
<div class="small-12 medium-3 column highlight padding">
@@ -24,12 +24,12 @@
<div class="small-12 medium-3 column">
<label><%= t("admin.poll_shifts.new.date") %></label>
<%= select 'shift[date]', 'vote_collection_date',
options_for_select(shift_vote_collection_dates(@booth, @booth.polls.current_or_incoming)),
{ prompt: t("admin.poll_shifts.new.select_date"),
options_for_select(shift_vote_collection_dates(@booth, @vote_collection_polls)),
{ prompt: @voting_polls.present? ? t("admin.poll_shifts.new.select_date") : t("admin.poll_shifts.new.no_voting_days"),
label: false },
class: 'js-shift-vote-collection-dates' %>
<%= select 'shift[date]', 'recount_scrutiny_date',
options_for_select(shift_recount_scrutiny_dates(@booth, @booth.polls.current_or_recounting_or_incoming)),
options_for_select(shift_recount_scrutiny_dates(@booth, @recount_polls)),
{ prompt: t("admin.poll_shifts.new.select_date"),
label: false },
class: 'js-shift-recount-scrutiny-dates',

View File

@@ -515,6 +515,7 @@ en:
search_officer_placeholder: Search officer
search_officer_text: Search for an officer to assign a new shift
select_date: "Select day"
no_voting_days: "Los dias de votación terminaron"
select_task: "Select task"
table_shift: "Shift"
table_email: "Email"

View File

@@ -515,6 +515,7 @@ es:
search_officer_placeholder: Buscar presidentes de mesa
search_officer_text: Busca al presidente de mesa para asignar un turno
select_date: "Seleccionar día"
no_voting_days: "Voting days ended"
select_task: "Seleccionar tarea"
table_shift: "Turno"
table_email: "Email"