@@ -8,7 +8,7 @@ class Admin::Poll::OfficerAssignmentsController < Admin::BaseController
|
||||
@officer = ::Poll::Officer.includes(:user).find(officer_assignment_params[:officer])
|
||||
@officer_assignments = ::Poll::OfficerAssignment.
|
||||
joins(:booth_assignment).
|
||||
includes(booth_assignment: :booth).
|
||||
includes(:recount, :final_recounts, booth_assignment: :booth).
|
||||
where("officer_id = ? AND poll_booth_assignments.poll_id = ?", @officer.id, @poll.id).
|
||||
order(:date)
|
||||
end
|
||||
|
||||
@@ -8,7 +8,7 @@ class Admin::Poll::PollsController < Admin::BaseController
|
||||
end
|
||||
|
||||
def show
|
||||
@poll = Poll.includes(:questions, booth_assignments: [:booth], officers: [:user]).order('poll_questions.title', 'poll_booths.name', 'users.username').find(params[:id])
|
||||
@poll = Poll.includes(:questions, booth_assignments: [:booth, :final_recounts, :recounts], officers: [:user]).order('poll_questions.title', 'poll_booths.name', 'users.username').find(params[:id])
|
||||
end
|
||||
|
||||
def new
|
||||
|
||||
@@ -65,5 +65,59 @@
|
||||
</table>
|
||||
<% end %>
|
||||
|
||||
<% voting_days_officer_assignments = @officer_assignments.select{|oa| oa.final == false} %>
|
||||
<% if voting_days_officer_assignments.any? %>
|
||||
<h3><%= t("admin.poll_officer_assignments.index.recounts") %></h3>
|
||||
<table id="recount_list">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><%= t("admin.poll_officer_assignments.index.date") %></th>
|
||||
<th><%= t("admin.poll_officer_assignments.index.booth") %></th>
|
||||
<th><%= t("admin.poll_officer_assignments.index.recount") %></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% voting_days_officer_assignments.each do |officer_assignment| %>
|
||||
<tr id="recount_<%= officer_assignment.date.to_date.strftime('%Y%m%d') %>">
|
||||
<td><%= l(officer_assignment.date.to_date) %></td>
|
||||
<td><%= booth_name_with_location(officer_assignment.booth_assignment.booth) %></td>
|
||||
<% if officer_assignment.recount.present? %>
|
||||
<td><%= officer_assignment.recount.count %></td>
|
||||
<% else %>
|
||||
<td> - </td>
|
||||
<% end %>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
<% end %>
|
||||
|
||||
<% final_officer_assignments = @officer_assignments.select{|oa| oa.final == true} %>
|
||||
<% if final_officer_assignments.any? %>
|
||||
<h3><%= t("admin.poll_officer_assignments.index.final_recounts") %></h3>
|
||||
<table id="final_recount_list">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><%= t("admin.poll_officer_assignments.index.date") %></th>
|
||||
<th><%= t("admin.poll_officer_assignments.index.booth") %></th>
|
||||
<th><%= t("admin.poll_officer_assignments.index.final_recount") %></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% final_officer_assignments.each do |officer_assignment| %>
|
||||
<tr id="final_recount_<%= officer_assignment.date.to_date.strftime('%Y%m%d') %>">
|
||||
<td><%= l(officer_assignment.date.to_date) %></td>
|
||||
<td><%= booth_name_with_location(officer_assignment.booth_assignment.booth) %></td>
|
||||
<% if officer_assignment.final_recounts.any? %>
|
||||
<td><%= officer_assignment.final_recounts.to_a.sum(&:count) %></td>
|
||||
<% else %>
|
||||
<td> - </td>
|
||||
<% end %>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
<% end %>
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<%= t("admin.polls.show.no_booths") %>
|
||||
</div>
|
||||
<% else %>
|
||||
<table class="margin">
|
||||
<table id="assigned_booths_list" class="margin">
|
||||
<thead>
|
||||
<th><%= t("admin.polls.show.table_name") %></th>
|
||||
<th><%= t("admin.polls.show.table_location") %></th>
|
||||
|
||||
@@ -17,4 +17,9 @@
|
||||
(<%= @poll.officers.uniq.count %>)
|
||||
<% end %>
|
||||
</li>
|
||||
<li class="tabs-title">
|
||||
<%= link_to "#tab-recounts" do %>
|
||||
<%= t("admin.polls.show.recounts_tab") %>
|
||||
<% end %>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
36
app/views/admin/poll/polls/_recounting.html.erb
Normal file
36
app/views/admin/poll/polls/_recounting.html.erb
Normal file
@@ -0,0 +1,36 @@
|
||||
<h3><%= t("admin.polls.show.recounting_title") %></h3>
|
||||
|
||||
<% if @poll.booth_assignments.empty? %>
|
||||
<div class="callout primary margin-top">
|
||||
<%= t("admin.polls.show.no_recounts") %>
|
||||
</div>
|
||||
<% else %>
|
||||
<table class="margin">
|
||||
<thead>
|
||||
<th><%= t("admin.polls.show.table_booth_name") %></th>
|
||||
<th class="text-center"><%= t("admin.polls.show.table_recounts") %></th>
|
||||
<th class="text-center"><%= t("admin.polls.show.table_final_recount") %></th>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @poll.booth_assignments.each do |booth_assignment| %>
|
||||
<tr id="<%= dom_id(booth_assignment) %>_recounts" class="booth_recounts">
|
||||
<td>
|
||||
<strong>
|
||||
<%= link_to booth_assignment.booth.name, admin_poll_booth_assignment_path(@poll, booth_assignment, anchor: 'tab-recounts') %>
|
||||
</strong>
|
||||
</td>
|
||||
<% if booth_assignment.recounts.any? %>
|
||||
<td class="text-center"><%= booth_assignment.recounts.to_a.sum(&:count) %></td>
|
||||
<% else %>
|
||||
<td class="text-center"> - </td>
|
||||
<% end %>
|
||||
<% if booth_assignment.final_recounts.any? %>
|
||||
<td class="text-center"><strong><%= booth_assignment.final_recounts.to_a.sum(&:count) %></strong></td>
|
||||
<% else %>
|
||||
<td class="text-center"> - </td>
|
||||
<% end %>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
<% end %>
|
||||
@@ -33,4 +33,8 @@
|
||||
<%= render "search_officers" %>
|
||||
<%= render 'officers' %>
|
||||
</div>
|
||||
|
||||
<div class="tabs-panel" id="tab-recounts">
|
||||
<%= render 'recounting' %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -52,8 +52,7 @@
|
||||
<th><%= t("officing.final_recounts.new.date") %></th>
|
||||
<th><%= t("officing.final_recounts.new.booth") %></th>
|
||||
<th><%= t("officing.final_recounts.new.count") %></th>
|
||||
<th><%= "Recuento diario anterior" %></th>
|
||||
<th><%= "Recuento del sistema" %></th>
|
||||
<th><%= t("officing.final_recounts.new.system_count") %></th>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @final_recounts.each do |final_recount| %>
|
||||
@@ -67,9 +66,6 @@
|
||||
<td>
|
||||
<strong><%= final_recount.count %></strong>
|
||||
</td>
|
||||
<td>
|
||||
<strong><%= recount_to_compare_with_final_recount final_recount %></strong>
|
||||
</td>
|
||||
<td>
|
||||
<strong><%= system_recount_to_compare_with_final_recount final_recount %></strong>
|
||||
</td>
|
||||
|
||||
@@ -277,6 +277,10 @@ en:
|
||||
remove_assignment: "Remove"
|
||||
assignments: "Officing shifts in this poll"
|
||||
no_assignments: "This user has no officing shifts in this poll."
|
||||
recounts: "Daily recounts"
|
||||
recount: "Recount"
|
||||
final_recounts: "Final recounts"
|
||||
final_recount: "Final recount"
|
||||
poll_booth_assignments:
|
||||
show:
|
||||
location: "Location"
|
||||
@@ -307,13 +311,16 @@ en:
|
||||
questions_tab: Questions
|
||||
booths_tab: Booths
|
||||
officers_tab: Officers
|
||||
recounts_tab: Recounting
|
||||
no_booths: "There are no booths assigned to this poll."
|
||||
no_questions: "There are no questions assigned to this poll."
|
||||
no_officers: "There are no officers assigned to this poll."
|
||||
no_recounts: "There is nothing to be recounted"
|
||||
remove_booth: "Remove booth from poll"
|
||||
booths_title: "List of booths"
|
||||
officers_title: "List of officers"
|
||||
questions_title: "List of questions"
|
||||
recounting_title: "Recounts"
|
||||
remove_question: "Remove question from poll"
|
||||
add_booth: "Assign booth"
|
||||
add_question: "Include question"
|
||||
@@ -326,6 +333,9 @@ en:
|
||||
table_name: "Name"
|
||||
table_location: "Location"
|
||||
table_email: "Email"
|
||||
table_booth_name: "Booth"
|
||||
table_final_recount: "Final recount"
|
||||
table_recounts: "Accumulated daily recounts"
|
||||
flash:
|
||||
question_added: "Question added to this poll"
|
||||
error_on_question_added: "Question could not be assigned to this poll"
|
||||
|
||||
@@ -277,6 +277,10 @@ es:
|
||||
remove_assignment: "Eliminar turno"
|
||||
assignments: "Turnos como presidente de mesa en esta votación"
|
||||
no_assignments: "No tiene turnos como presidente de mesa en esta votación."
|
||||
recounts: "Recuentos diarios"
|
||||
recount: "Recuento"
|
||||
final_recounts: "Recuentos finales"
|
||||
final_recount: "Recuento total"
|
||||
poll_booth_assignments:
|
||||
show:
|
||||
location: "Ubicación"
|
||||
@@ -307,13 +311,16 @@ es:
|
||||
questions_tab: Preguntas
|
||||
booths_tab: Urnas
|
||||
officers_tab: Presidentes de mesa
|
||||
recounts_tab: Recuentos
|
||||
no_booths: "No hay urnas asignadas a esta votación."
|
||||
no_questions: "No hay preguntas asignadas a esta votación."
|
||||
no_officers: "No hay presidentes de mesa asignados a esta votación."
|
||||
no_recounts: "No hay nada de lo que hacer recuento"
|
||||
remove_booth: "Desasignar urna"
|
||||
booths_title: "Listado de urnas asignadas"
|
||||
officers_title: "Listado de presidentes de mesa asignados"
|
||||
questions_title: "Listado de preguntas asignadas"
|
||||
recounting_title: "Recuentos"
|
||||
remove_question: "Desasignar pregunta"
|
||||
add_booth: "Asignar urna"
|
||||
add_question: "Incluir pregunta"
|
||||
@@ -326,6 +333,9 @@ es:
|
||||
table_name: "Nombre"
|
||||
table_location: "Ubicación"
|
||||
table_email: "Email"
|
||||
table_booth_name: "Urna"
|
||||
table_final_recount: "Recuento final"
|
||||
table_recounts: "Recuentos diarios acumulados"
|
||||
flash:
|
||||
question_added: "Pregunta añadida a esta votación"
|
||||
error_on_question_added: "No se pudo asignar la pregunta"
|
||||
|
||||
@@ -50,6 +50,7 @@ en:
|
||||
count_placeholder: "Final vote count"
|
||||
submit: Save
|
||||
final_recount_list: "Your final recounts"
|
||||
system_count: "System recount"
|
||||
residence:
|
||||
flash:
|
||||
create: "Document verified with Census"
|
||||
|
||||
@@ -6,9 +6,9 @@ es:
|
||||
title: Presidir mesa de votaciones
|
||||
info: Aquí puedes validar documentos de ciudadanos y guardar los resultados de las urnas
|
||||
menu:
|
||||
voters: "Validar documento"
|
||||
recounts: "Guardar recuento"
|
||||
final_recounts: "Recuentos finales"
|
||||
voters: "Validar documento y votar"
|
||||
recounts: "Recuento diario"
|
||||
final_recounts: "Recuento final y escrutinio"
|
||||
polls:
|
||||
index:
|
||||
title: "Listado de votaciones"
|
||||
@@ -50,6 +50,7 @@ es:
|
||||
count_placeholder: "Número final de votos"
|
||||
submit: "Guardar"
|
||||
final_recount_list: "Tus recuentos finales"
|
||||
system_count: "Recuento del sistema"
|
||||
residence:
|
||||
flash:
|
||||
create: "Documento verificado con el Padrón"
|
||||
|
||||
@@ -80,7 +80,7 @@ feature 'Admin booths assignments' do
|
||||
visit admin_poll_path(poll)
|
||||
click_link 'Booths (2)'
|
||||
|
||||
click_link booth.name
|
||||
within('#assigned_booths_list') { click_link booth.name }
|
||||
|
||||
click_link 'Officers'
|
||||
within('#officers_list') do
|
||||
@@ -119,7 +119,7 @@ feature 'Admin booths assignments' do
|
||||
visit admin_poll_path(poll)
|
||||
click_link 'Booths (2)'
|
||||
|
||||
click_link booth.name
|
||||
within('#assigned_booths_list') { click_link booth.name }
|
||||
|
||||
click_link 'Recounts'
|
||||
within('#recounts_list') do
|
||||
|
||||
@@ -48,7 +48,7 @@ feature 'Admin officer assignments in poll' do
|
||||
expect(page).to have_content officer.email
|
||||
end
|
||||
|
||||
scenario 'remove booth from poll' do
|
||||
scenario 'Remove officer assignment from poll' do
|
||||
officer_assignment = create(:poll_officer_assignment)
|
||||
poll = officer_assignment.booth_assignment.poll
|
||||
booth = officer_assignment.booth_assignment.booth
|
||||
@@ -65,4 +65,33 @@ feature 'Admin officer assignments in poll' do
|
||||
expect(page).to have_content 'Officing shift removed'
|
||||
expect(page).to have_content 'This user has no officing shifts in this poll'
|
||||
end
|
||||
|
||||
scenario 'Index view shows recounts info for officer' do
|
||||
booth_assignment = create(:poll_booth_assignment)
|
||||
poll = booth_assignment.poll
|
||||
officer = create(:poll_officer)
|
||||
officer_assignment = create(:poll_officer_assignment,
|
||||
booth_assignment: booth_assignment,
|
||||
officer: officer,
|
||||
date: poll.starts_at)
|
||||
final_officer_assignment = create(:poll_officer_assignment, :final,
|
||||
booth_assignment: booth_assignment,
|
||||
officer: officer,
|
||||
date: poll.ends_at + 1.day)
|
||||
recount = create(:poll_recount,
|
||||
booth_assignment: booth_assignment,
|
||||
officer_assignment: officer_assignment,
|
||||
date: officer_assignment.date,
|
||||
count: 77)
|
||||
final_recount = create(:poll_final_recount,
|
||||
booth_assignment: booth_assignment,
|
||||
officer_assignment: final_officer_assignment,
|
||||
date: poll.ends_at,
|
||||
count: 9876)
|
||||
|
||||
visit admin_officer_assignments_path(poll: poll, officer: officer)
|
||||
|
||||
within('#recount_list') { expect(page).to have_content('77') }
|
||||
within('#final_recount_list') { expect(page).to have_content('9876') }
|
||||
end
|
||||
end
|
||||
@@ -165,6 +165,7 @@ feature 'Admin polls' do
|
||||
end
|
||||
|
||||
context "Questions" do
|
||||
|
||||
context "Poll show" do
|
||||
|
||||
scenario "Question list", :js do
|
||||
@@ -240,5 +241,67 @@ feature 'Admin polls' do
|
||||
end
|
||||
end
|
||||
|
||||
context "Recounting" do
|
||||
context "Poll show" do
|
||||
scenario "No recounts", :js do
|
||||
poll = create(:poll)
|
||||
visit admin_poll_path(poll)
|
||||
click_link "Recounting"
|
||||
|
||||
expect(page).to have_content "There is nothing to be recounted"
|
||||
end
|
||||
|
||||
scenario "Recounts list", :js do
|
||||
poll = create(:poll)
|
||||
booth_assignment = create(:poll_booth_assignment, poll: poll)
|
||||
booth_assignment_recounted = create(:poll_booth_assignment, poll: poll)
|
||||
booth_assignment_final_recounted = create(:poll_booth_assignment, poll: poll)
|
||||
|
||||
3.times { |i| create(:poll_recount,
|
||||
booth_assignment: booth_assignment,
|
||||
date: poll.starts_at + i.days,
|
||||
count: 33) }
|
||||
|
||||
3.times { |i| create(:poll_final_recount,
|
||||
booth_assignment: booth_assignment,
|
||||
date: poll.starts_at + i.days,
|
||||
count: 21) }
|
||||
|
||||
create(:poll_recount,
|
||||
booth_assignment: booth_assignment_recounted,
|
||||
date: poll.ends_at,
|
||||
count: 777)
|
||||
|
||||
create(:poll_final_recount,
|
||||
booth_assignment: booth_assignment_final_recounted,
|
||||
date: poll.ends_at,
|
||||
count: 55555)
|
||||
|
||||
visit admin_poll_path(poll)
|
||||
|
||||
click_link "Recounting"
|
||||
|
||||
expect(page).to have_css ".booth_recounts", count: 3
|
||||
|
||||
within("#poll_booth_assignment_#{booth_assignment.id}_recounts") do
|
||||
expect(page).to have_content(booth_assignment.booth.name)
|
||||
expect(page).to have_content('99')
|
||||
expect(page).to have_content('63')
|
||||
end
|
||||
|
||||
within("#poll_booth_assignment_#{booth_assignment_recounted.id}_recounts") do
|
||||
expect(page).to have_content(booth_assignment_recounted.booth.name)
|
||||
expect(page).to have_content('777')
|
||||
expect(page).to have_content('-')
|
||||
end
|
||||
|
||||
within("#poll_booth_assignment_#{booth_assignment_final_recounted.id}_recounts") do
|
||||
expect(page).to have_content(booth_assignment_final_recounted.booth.name)
|
||||
expect(page).to have_content('-')
|
||||
expect(page).to have_content('55555')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@@ -98,34 +98,24 @@ feature 'Officing Final Recount' do
|
||||
expect(page).to_not have_content('100')
|
||||
end
|
||||
|
||||
scenario 'Show daily, final and system recounts to compare' do
|
||||
voting_officer_assignment = create(:poll_officer_assignment, date: 7.days.ago)
|
||||
poll = voting_officer_assignment.booth_assignment.poll
|
||||
scenario 'Show final and system recounts to compare' do
|
||||
final_officer_assignment = create(:poll_officer_assignment, :final, officer: @poll_officer)
|
||||
poll = final_officer_assignment.booth_assignment.poll
|
||||
poll.update(ends_at: 1.day.ago)
|
||||
daily_recount = create(:poll_recount,
|
||||
officer_assignment: voting_officer_assignment,
|
||||
booth_assignment: voting_officer_assignment.booth_assignment,
|
||||
date: voting_officer_assignment.date,
|
||||
count: 500)
|
||||
final_officer_assignment = create(:poll_officer_assignment, :final,
|
||||
booth_assignment: voting_officer_assignment.booth_assignment,
|
||||
date: poll.ends_at + 1.day,
|
||||
officer: @poll_officer)
|
||||
final_recount = create(:poll_final_recount,
|
||||
officer_assignment: final_officer_assignment,
|
||||
booth_assignment: final_officer_assignment.booth_assignment,
|
||||
date: daily_recount.date,
|
||||
date: 7.days.ago,
|
||||
count: 100)
|
||||
33.times { create(:poll_voter, :valid_document,
|
||||
poll: poll,
|
||||
booth_assignment: final_officer_assignment.booth_assignment,
|
||||
created_at: daily_recount.date) }
|
||||
created_at: final_recount.date) }
|
||||
|
||||
visit new_officing_poll_final_recount_path(poll)
|
||||
within("#poll_final_recount_#{final_recount.id}") do
|
||||
expect(page).to have_content(I18n.l(final_recount.date.to_date, format: :long))
|
||||
expect(page).to have_content(final_officer_assignment.booth_assignment.booth.name)
|
||||
expect(page).to have_content('500')
|
||||
expect(page).to have_content('100')
|
||||
expect(page).to have_content('33')
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user