adds Recounting tab to Poll's admin show view
This commit is contained in:
@@ -8,7 +8,7 @@ class Admin::Poll::PollsController < Admin::BaseController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def show
|
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
|
end
|
||||||
|
|
||||||
def new
|
def new
|
||||||
|
|||||||
@@ -17,4 +17,9 @@
|
|||||||
(<%= @poll.officers.uniq.count %>)
|
(<%= @poll.officers.uniq.count %>)
|
||||||
<% end %>
|
<% end %>
|
||||||
</li>
|
</li>
|
||||||
|
<li class="tabs-title">
|
||||||
|
<%= link_to "#tab-recounts" do %>
|
||||||
|
<%= t("admin.polls.show.recounts_tab") %>
|
||||||
|
<% end %>
|
||||||
|
</li>
|
||||||
</ul>
|
</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 "search_officers" %>
|
||||||
<%= render 'officers' %>
|
<%= render 'officers' %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="tabs-panel" id="tab-recounts">
|
||||||
|
<%= render 'recounting' %>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -311,13 +311,16 @@ en:
|
|||||||
questions_tab: Questions
|
questions_tab: Questions
|
||||||
booths_tab: Booths
|
booths_tab: Booths
|
||||||
officers_tab: Officers
|
officers_tab: Officers
|
||||||
|
recounts_tab: Recounting
|
||||||
no_booths: "There are no booths assigned to this poll."
|
no_booths: "There are no booths assigned to this poll."
|
||||||
no_questions: "There are no questions 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_officers: "There are no officers assigned to this poll."
|
||||||
|
no_recounts: "There is nothing to be recounted"
|
||||||
remove_booth: "Remove booth from poll"
|
remove_booth: "Remove booth from poll"
|
||||||
booths_title: "List of booths"
|
booths_title: "List of booths"
|
||||||
officers_title: "List of officers"
|
officers_title: "List of officers"
|
||||||
questions_title: "List of questions"
|
questions_title: "List of questions"
|
||||||
|
recounting_title: "Recounts"
|
||||||
remove_question: "Remove question from poll"
|
remove_question: "Remove question from poll"
|
||||||
add_booth: "Assign booth"
|
add_booth: "Assign booth"
|
||||||
add_question: "Include question"
|
add_question: "Include question"
|
||||||
@@ -330,6 +333,9 @@ en:
|
|||||||
table_name: "Name"
|
table_name: "Name"
|
||||||
table_location: "Location"
|
table_location: "Location"
|
||||||
table_email: "Email"
|
table_email: "Email"
|
||||||
|
table_booth_name: "Booth"
|
||||||
|
table_final_recount: "Final recount"
|
||||||
|
table_recounts: "Accumulated daily recounts"
|
||||||
flash:
|
flash:
|
||||||
question_added: "Question added to this poll"
|
question_added: "Question added to this poll"
|
||||||
error_on_question_added: "Question could not be assigned to this poll"
|
error_on_question_added: "Question could not be assigned to this poll"
|
||||||
|
|||||||
@@ -311,13 +311,16 @@ es:
|
|||||||
questions_tab: Preguntas
|
questions_tab: Preguntas
|
||||||
booths_tab: Urnas
|
booths_tab: Urnas
|
||||||
officers_tab: Presidentes de mesa
|
officers_tab: Presidentes de mesa
|
||||||
|
recounts_tab: Recuentos
|
||||||
no_booths: "No hay urnas asignadas a esta votación."
|
no_booths: "No hay urnas asignadas a esta votación."
|
||||||
no_questions: "No hay preguntas 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_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"
|
remove_booth: "Desasignar urna"
|
||||||
booths_title: "Listado de urnas asignadas"
|
booths_title: "Listado de urnas asignadas"
|
||||||
officers_title: "Listado de presidentes de mesa asignados"
|
officers_title: "Listado de presidentes de mesa asignados"
|
||||||
questions_title: "Listado de preguntas asignadas"
|
questions_title: "Listado de preguntas asignadas"
|
||||||
|
recounting_title: "Recuentos"
|
||||||
remove_question: "Desasignar pregunta"
|
remove_question: "Desasignar pregunta"
|
||||||
add_booth: "Asignar urna"
|
add_booth: "Asignar urna"
|
||||||
add_question: "Incluir pregunta"
|
add_question: "Incluir pregunta"
|
||||||
@@ -330,6 +333,9 @@ es:
|
|||||||
table_name: "Nombre"
|
table_name: "Nombre"
|
||||||
table_location: "Ubicación"
|
table_location: "Ubicación"
|
||||||
table_email: "Email"
|
table_email: "Email"
|
||||||
|
table_booth_name: "Urna"
|
||||||
|
table_final_recount: "Recuento final"
|
||||||
|
table_recounts: "Recuentos diarios acumulados"
|
||||||
flash:
|
flash:
|
||||||
question_added: "Pregunta añadida a esta votación"
|
question_added: "Pregunta añadida a esta votación"
|
||||||
error_on_question_added: "No se pudo asignar la pregunta"
|
error_on_question_added: "No se pudo asignar la pregunta"
|
||||||
|
|||||||
@@ -165,6 +165,7 @@ feature 'Admin polls' do
|
|||||||
end
|
end
|
||||||
|
|
||||||
context "Questions" do
|
context "Questions" do
|
||||||
|
|
||||||
context "Poll show" do
|
context "Poll show" do
|
||||||
|
|
||||||
scenario "Question list", :js do
|
scenario "Question list", :js do
|
||||||
@@ -240,5 +241,67 @@ feature 'Admin polls' do
|
|||||||
end
|
end
|
||||||
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
|
end
|
||||||
Reference in New Issue
Block a user