Fix Shift date ranges when poll is on recounting phase
This commit is contained in:
@@ -6,6 +6,8 @@ class Admin::Poll::ShiftsController < Admin::Poll::BaseController
|
|||||||
def new
|
def new
|
||||||
load_shifts
|
load_shifts
|
||||||
@shift = ::Poll::Shift.new
|
@shift = ::Poll::Shift.new
|
||||||
|
@voting_polls = @booth.polls.current_or_incoming
|
||||||
|
@recount_polls = @booth.polls.current_or_recounting_or_incoming
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
module ShiftsHelper
|
module ShiftsHelper
|
||||||
|
|
||||||
def shift_vote_collection_dates(booth, polls)
|
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)
|
date_options((start_date(polls)..end_date(polls)), Poll::Shift.tasks[:vote_collection], booth)
|
||||||
end
|
end
|
||||||
|
|
||||||
def shift_recount_scrutiny_dates(booth, polls)
|
def shift_recount_scrutiny_dates(booth, polls)
|
||||||
|
return [] if polls.blank?
|
||||||
dates = polls.map(&:ends_at).map(&:to_date).sort.inject([]) do |total, date|
|
dates = polls.map(&:ends_at).map(&:to_date).sort.inject([]) do |total, date|
|
||||||
initial_date = date < Date.current ? Date.current : date
|
initial_date = date < Date.current ? Date.current : date
|
||||||
total << (initial_date..date + Poll::RECOUNT_DURATION).to_a
|
total << (initial_date..date + Poll::RECOUNT_DURATION).to_a
|
||||||
|
|||||||
@@ -24,12 +24,12 @@
|
|||||||
<div class="small-12 medium-3 column">
|
<div class="small-12 medium-3 column">
|
||||||
<label><%= t("admin.poll_shifts.new.date") %></label>
|
<label><%= t("admin.poll_shifts.new.date") %></label>
|
||||||
<%= select 'shift[date]', 'vote_collection_date',
|
<%= select 'shift[date]', 'vote_collection_date',
|
||||||
options_for_select(shift_vote_collection_dates(@booth, @booth.polls.current_or_incoming)),
|
options_for_select(shift_vote_collection_dates(@booth, @vote_collection_polls)),
|
||||||
{ prompt: t("admin.poll_shifts.new.select_date"),
|
{ prompt: @voting_polls.present? ? t("admin.poll_shifts.new.select_date") : t("admin.poll_shifts.new.no_voting_days"),
|
||||||
label: false },
|
label: false },
|
||||||
class: 'js-shift-vote-collection-dates' %>
|
class: 'js-shift-vote-collection-dates' %>
|
||||||
<%= select 'shift[date]', 'recount_scrutiny_date',
|
<%= 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"),
|
{ prompt: t("admin.poll_shifts.new.select_date"),
|
||||||
label: false },
|
label: false },
|
||||||
class: 'js-shift-recount-scrutiny-dates',
|
class: 'js-shift-recount-scrutiny-dates',
|
||||||
|
|||||||
@@ -515,6 +515,7 @@ en:
|
|||||||
search_officer_placeholder: Search officer
|
search_officer_placeholder: Search officer
|
||||||
search_officer_text: Search for an officer to assign a new shift
|
search_officer_text: Search for an officer to assign a new shift
|
||||||
select_date: "Select day"
|
select_date: "Select day"
|
||||||
|
no_voting_days: "Los dias de votación terminaron"
|
||||||
select_task: "Select task"
|
select_task: "Select task"
|
||||||
table_shift: "Shift"
|
table_shift: "Shift"
|
||||||
table_email: "Email"
|
table_email: "Email"
|
||||||
|
|||||||
@@ -515,6 +515,7 @@ es:
|
|||||||
search_officer_placeholder: Buscar presidentes de mesa
|
search_officer_placeholder: Buscar presidentes de mesa
|
||||||
search_officer_text: Busca al presidente de mesa para asignar un turno
|
search_officer_text: Busca al presidente de mesa para asignar un turno
|
||||||
select_date: "Seleccionar día"
|
select_date: "Seleccionar día"
|
||||||
|
no_voting_days: "Voting days ended"
|
||||||
select_task: "Seleccionar tarea"
|
select_task: "Seleccionar tarea"
|
||||||
table_shift: "Turno"
|
table_shift: "Turno"
|
||||||
table_email: "Email"
|
table_email: "Email"
|
||||||
|
|||||||
Reference in New Issue
Block a user