adds recounts to poll_officer view in admin zone
Admin can see recounts and final recounts made by poll_officer next to their officing shifts
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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 %>
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user