adds final recounts info to admins
This commit is contained in:
@@ -24,7 +24,7 @@ class Admin::Poll::BoothAssignmentsController < Admin::BaseController
|
|||||||
|
|
||||||
def show
|
def show
|
||||||
@poll = ::Poll.find(params[:poll_id])
|
@poll = ::Poll.find(params[:poll_id])
|
||||||
@booth_assignment = @poll.booth_assignments.includes(:recounts, :voters, officer_assignments: [officer: [:user]]).find(params[:id])
|
@booth_assignment = @poll.booth_assignments.includes(:recounts, :final_recounts, :voters, officer_assignments: [officer: [:user]]).find(params[:id])
|
||||||
@voters_by_date = @booth_assignment.voters.group_by {|v| v.created_at.to_date}
|
@voters_by_date = @booth_assignment.voters.group_by {|v| v.created_at.to_date}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
7
app/helpers/poll_final_recounts_helper.rb
Normal file
7
app/helpers/poll_final_recounts_helper.rb
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
module PollFinalRecountsHelper
|
||||||
|
|
||||||
|
def final_recount_for_date(final_recounts, date)
|
||||||
|
final_recounts.select {|f| f.date == date}.first
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
module PollRecountsHelper
|
module PollRecountsHelper
|
||||||
|
|
||||||
def recount_for_date(recounts, date)
|
def recount_for_date(recounts, date)
|
||||||
recounts.select {|r| r.date.to_date == date}.first
|
recounts.select {|r| r.date == date}.first
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@@ -55,26 +55,30 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th><%= t("admin.poll_booth_assignments.show.date") %></th>
|
<th><%= t("admin.poll_booth_assignments.show.date") %></th>
|
||||||
<th class="text-center"><%= t("admin.poll_booth_assignments.show.count_by_officer") %></th>
|
<th class="text-center"><%= t("admin.poll_booth_assignments.show.count_by_officer") %></th>
|
||||||
|
<th class="text-center"><%= t("admin.poll_booth_assignments.show.count_final") %></th>
|
||||||
<th class="text-center"><%= t("admin.poll_booth_assignments.show.count_by_system") %></th>
|
<th class="text-center"><%= t("admin.poll_booth_assignments.show.count_by_system") %></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<% (@poll.starts_at.to_date..@poll.ends_at.to_date).each do |voting_date| %>
|
<% (@poll.starts_at.to_date..@poll.ends_at.to_date).each do |voting_date| %>
|
||||||
<% recount = recount_for_date(@booth_assignment.recounts, voting_date) %>
|
<% recount = recount_for_date(@booth_assignment.recounts, voting_date) %>
|
||||||
|
<% final_recount = final_recount_for_date(@booth_assignment.final_recounts, voting_date) %>
|
||||||
<% system_count = @voters_by_date[voting_date].present? ? @voters_by_date[voting_date].size : 0 %>
|
<% system_count = @voters_by_date[voting_date].present? ? @voters_by_date[voting_date].size : 0 %>
|
||||||
<% if recount.present? %>
|
<tr id="recounting_<%= voting_date.strftime('%Y%m%d') %>">
|
||||||
<tr id="recount_<%= recount.id %>" class="<%= 'count-error' if recount.count != system_count %>">
|
<td><%= l voting_date %></td>
|
||||||
<td><%= l voting_date %></td>
|
<% if recount.present? %>
|
||||||
<td class="text-center" title="<%= recount.officer_assignment.officer.name %>"><%= recount.count %></td>
|
|
||||||
<td class="text-center"><%= system_count %></td>
|
<td class="text-center <%= 'count-error' if recount.count != system_count %>" title="<%= recount.officer_assignment.officer.name %>"><%= recount.count %></td>
|
||||||
</tr>
|
<% else %>
|
||||||
<% else %>
|
|
||||||
<tr id="recount_<%= voting_date.strftime('%Y%m%d') %>">
|
|
||||||
<td><%= l voting_date %></td>
|
|
||||||
<td class="text-center" title=""> - </td>
|
<td class="text-center" title=""> - </td>
|
||||||
<td class="text-center"><%= system_count %></td>
|
<% end %>
|
||||||
</tr>
|
<% if final_recount.present? %>
|
||||||
<% end %>
|
<td class="text-center <%= 'count-error' if final_recount.count != system_count %>" title="<%= final_recount.officer_assignment.officer.name %>"><%= final_recount.count %></td>
|
||||||
|
<% else %>
|
||||||
|
<td class="text-center" title=""> - </td>
|
||||||
|
<% end %>
|
||||||
|
<td class="text-center"><%= system_count %></td>
|
||||||
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
@@ -288,6 +288,7 @@ en:
|
|||||||
no_recounts: "There are not daily recounts of this booth yet"
|
no_recounts: "There are not daily recounts of this booth yet"
|
||||||
date: "Date"
|
date: "Date"
|
||||||
count_by_officer: "Votes (by officer)"
|
count_by_officer: "Votes (by officer)"
|
||||||
|
count_final: "Final recount"
|
||||||
count_by_system: "Votes (automatic)"
|
count_by_system: "Votes (automatic)"
|
||||||
polls:
|
polls:
|
||||||
index:
|
index:
|
||||||
|
|||||||
@@ -288,6 +288,7 @@ es:
|
|||||||
no_recounts: "No hay recuentos diarios de esta urna"
|
no_recounts: "No hay recuentos diarios de esta urna"
|
||||||
date: "Fecha"
|
date: "Fecha"
|
||||||
count_by_officer: "Votos (presidente de mesa)"
|
count_by_officer: "Votos (presidente de mesa)"
|
||||||
|
count_final: "Recuento final"
|
||||||
count_by_system: "Votos (automático)"
|
count_by_system: "Votos (automático)"
|
||||||
polls:
|
polls:
|
||||||
index:
|
index:
|
||||||
|
|||||||
@@ -90,11 +90,12 @@ feature 'Admin booths assignments' do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario 'Lists all recounts for the booth assignment' do
|
scenario 'Lists all recounts for the booth assignment' do
|
||||||
poll = create(:poll)
|
poll = create(:poll, starts_at: 2.weeks.ago, ends_at: 1.week.ago)
|
||||||
booth = create(:poll_booth)
|
booth = create(:poll_booth)
|
||||||
booth_assignment = create(:poll_booth_assignment, poll: poll, booth: booth)
|
booth_assignment = create(:poll_booth_assignment, poll: poll, booth: booth)
|
||||||
officer_assignment_1 = create(:poll_officer_assignment, booth_assignment: booth_assignment, date: poll.starts_at)
|
officer_assignment_1 = create(:poll_officer_assignment, booth_assignment: booth_assignment, date: poll.starts_at)
|
||||||
officer_assignment_2 = create(:poll_officer_assignment, booth_assignment: booth_assignment, date: poll.ends_at)
|
officer_assignment_2 = create(:poll_officer_assignment, booth_assignment: booth_assignment, date: poll.ends_at)
|
||||||
|
final_officer_assignment = create(:poll_officer_assignment, :final, booth_assignment: booth_assignment, date: poll.ends_at)
|
||||||
|
|
||||||
recount_1 = create(:poll_recount,
|
recount_1 = create(:poll_recount,
|
||||||
booth_assignment: booth_assignment,
|
booth_assignment: booth_assignment,
|
||||||
@@ -105,7 +106,12 @@ feature 'Admin booths assignments' do
|
|||||||
booth_assignment: booth_assignment,
|
booth_assignment: booth_assignment,
|
||||||
officer_assignment: officer_assignment_2,
|
officer_assignment: officer_assignment_2,
|
||||||
date: officer_assignment_2.date,
|
date: officer_assignment_2.date,
|
||||||
count: 1)
|
count: 78)
|
||||||
|
final_recount = create(:poll_final_recount,
|
||||||
|
booth_assignment: booth_assignment,
|
||||||
|
officer_assignment: final_officer_assignment,
|
||||||
|
date: final_officer_assignment.date,
|
||||||
|
count: 5678)
|
||||||
|
|
||||||
booth_assignment_2 = create(:poll_booth_assignment, poll: poll)
|
booth_assignment_2 = create(:poll_booth_assignment, poll: poll)
|
||||||
other_recount = create(:poll_recount, booth_assignment: booth_assignment_2, count: 100)
|
other_recount = create(:poll_recount, booth_assignment: booth_assignment_2, count: 100)
|
||||||
@@ -119,14 +125,18 @@ feature 'Admin booths assignments' do
|
|||||||
within('#recounts_list') do
|
within('#recounts_list') do
|
||||||
expect(page).to_not have_content other_recount.count
|
expect(page).to_not have_content other_recount.count
|
||||||
|
|
||||||
within("#recount_#{recount_1.id}") do
|
within("#recounting_#{recount_1.date.strftime('%Y%m%d')}") do
|
||||||
expect(page).to have_content recount_1.count
|
expect(page).to have_content recount_1.count
|
||||||
end
|
end
|
||||||
|
|
||||||
within("#recount_#{recount_2.id}") do
|
within("#recounting_#{recount_2.date.strftime('%Y%m%d')}") do
|
||||||
expect(page).to have_content recount_2.count
|
expect(page).to have_content recount_2.count
|
||||||
end
|
end
|
||||||
|
|
||||||
|
within("#recounting_#{final_recount.date.strftime('%Y%m%d')}") do
|
||||||
|
expect(page).to have_content final_recount.count
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -147,8 +157,8 @@ feature 'Admin booths assignments' do
|
|||||||
click_link 'Recounts'
|
click_link 'Recounts'
|
||||||
|
|
||||||
within('#recounts_list') do
|
within('#recounts_list') do
|
||||||
expect(page).to have_css("#recount_#{recount.id}.count-error")
|
expect(page).to have_css("#recounting_#{recount.date.strftime('%Y%m%d')} td.count-error")
|
||||||
within("#recount_#{recount.id}") do
|
within("#recounting_#{recount.date.strftime('%Y%m%d')}") do
|
||||||
expect(page).to have_content recount.count
|
expect(page).to have_content recount.count
|
||||||
expect(page).to have_content 0
|
expect(page).to have_content 0
|
||||||
end
|
end
|
||||||
@@ -161,7 +171,7 @@ feature 'Admin booths assignments' do
|
|||||||
|
|
||||||
within('#recounts_list') do
|
within('#recounts_list') do
|
||||||
expect(page).to_not have_css('.count-error')
|
expect(page).to_not have_css('.count-error')
|
||||||
within("#recount_#{recount.id}") do
|
within("#recounting_#{recount.date.strftime('%Y%m%d')}") do
|
||||||
expect(page).to have_content(recount.count)
|
expect(page).to have_content(recount.count)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user