Merge pull request #3342 from consul/backport-cumulative_totals

Add cumulative totals to admin poll recounts list
This commit is contained in:
Javier Martín
2019-03-07 19:01:22 +01:00
committed by GitHub
5 changed files with 38 additions and 0 deletions

View File

@@ -6,6 +6,10 @@ class Admin::Poll::RecountsController < Admin::Poll::BaseController
includes(:booth, :recounts, :voters).
order("poll_booths.name").
page(params[:page]).per(50)
@all_booths_counts = {
final: ::Poll::Recount.select(:total_amount).where(booth_assignment_id: @poll.booth_assignment_ids).sum(:total_amount),
system: ::Poll::Voter.where(booth_assignment_id: @poll.booth_assignment_ids).count
}
end
private

View File

@@ -9,6 +9,24 @@
<%= t("admin.recounts.index.no_recounts") %>
</div>
<% else %>
<table id="totals">
<thead>
<tr>
<th class="text-center"></th>
<th class="text-center"><%= t("admin.recounts.index.total_final") %></th>
<th class="text-center"><%= t("admin.recounts.index.total_system") %></th>
</tr>
</thead>
<tbody>
<tr>
<td><strong><%= t("admin.recounts.index.all_booths_total") %></strong></td>
<td class="text-center" id="total_final"><%= @all_booths_counts[:final] %></td>
<td class="text-center" id="total_system"><%= @all_booths_counts[:system] %></td>
</tr>
</tbody>
</table>
<table class="fixed margin">
<thead>
<th><%= t("admin.recounts.index.table_booth_name") %></th>

View File

@@ -1049,6 +1049,9 @@ en:
index:
title: "Recounts"
no_recounts: "There is nothing to be recounted"
all_booths_total: "Cumulative total from all booths:"
total_final: "Final recounts"
total_system: "Votes (automatic)"
table_booth_name: "Booth"
table_total_recount: "Total recount (by officer)"
table_system_count: "Votes (automatic)"

View File

@@ -1048,6 +1048,9 @@ es:
index:
title: "Recuentos"
no_recounts: "No hay nada de lo que hacer recuento"
all_booths_total: "Acumulado en todas las urnas:"
total_final: "Recuentos finales"
total_system: "Votos (automático)"
table_booth_name: "Urna"
table_total_recount: "Recuento total (presidente de mesa)"
table_system_count: "Votos (automático)"

View File

@@ -239,6 +239,16 @@ feature 'Admin polls' do
click_link "Recounting"
within("#totals") do
within("#total_final") do
expect(page).to have_content("#{55555 + 63}")
end
within("#total_system") do
expect(page).to have_content("2")
end
end
expect(page).to have_css ".booth_recounts", count: 3
within("#poll_booth_assignment_#{booth_assignment.id}_recounts") do