adds booth_assignment show with officers and recounts info
This commit is contained in:
@@ -1,7 +1,5 @@
|
|||||||
class Admin::Poll::BoothAssignmentsController < Admin::BaseController
|
class Admin::Poll::BoothAssignmentsController < Admin::BaseController
|
||||||
|
|
||||||
before_action :load_booth_assignment, only: :destroy
|
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@booth_assignment = ::Poll::BoothAssignment.new(poll_id: booth_assignment_params[:poll], booth_id: booth_assignment_params[:booth])
|
@booth_assignment = ::Poll::BoothAssignment.new(poll_id: booth_assignment_params[:poll], booth_id: booth_assignment_params[:booth])
|
||||||
|
|
||||||
@@ -14,6 +12,8 @@ class Admin::Poll::BoothAssignmentsController < Admin::BaseController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
|
@booth_assignment = ::Poll::BoothAssignment.find(params[:id])
|
||||||
|
|
||||||
if @booth_assignment.destroy
|
if @booth_assignment.destroy
|
||||||
notice = t("admin.booth_assignments.flash.destroy")
|
notice = t("admin.booth_assignments.flash.destroy")
|
||||||
else
|
else
|
||||||
@@ -22,10 +22,15 @@ class Admin::Poll::BoothAssignmentsController < Admin::BaseController
|
|||||||
redirect_to admin_poll_path(@booth_assignment.poll_id, anchor: 'tab-booths'), notice: notice
|
redirect_to admin_poll_path(@booth_assignment.poll_id, anchor: 'tab-booths'), notice: notice
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def show
|
||||||
|
@poll = ::Poll.find(params[:poll_id])
|
||||||
|
@booth_assignment = @poll.booth_assignments.includes(:recounts, officer_assignments: [officer: [:user]]).find(params[:id])
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def load_booth_assignment
|
def load_booth_assignment
|
||||||
@booth_assignment = ::Poll::BoothAssignment.find_by(poll: params[:poll], booth: params[:booth])
|
@booth_assignment = ::Poll::BoothAssignment.find(params[:id])
|
||||||
end
|
end
|
||||||
|
|
||||||
def booth_assignment_params
|
def booth_assignment_params
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ class Admin::Poll::PollsController < Admin::BaseController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@poll = Poll.includes(:questions, :booths, officers: [:user]).order('poll_questions.title', 'poll_booths.name', 'users.username').find(params[:id])
|
@poll = Poll.includes(:questions, booth_assignments: [:booth], officers: [:user]).order('poll_questions.title', 'poll_booths.name', 'users.username').find(params[:id])
|
||||||
end
|
end
|
||||||
|
|
||||||
def new
|
def new
|
||||||
|
|||||||
73
app/views/admin/poll/booth_assignments/show.html.erb
Normal file
73
app/views/admin/poll/booth_assignments/show.html.erb
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
<%= link_to admin_poll_path(@poll, anchor: 'tab-booths') do %>
|
||||||
|
<span class="icon-angle-left"></span>
|
||||||
|
<%= @poll.name %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<h2><%= @booth_assignment.booth.name %></h2>
|
||||||
|
|
||||||
|
<% if @booth_assignment.booth.location.present? %>
|
||||||
|
<p>
|
||||||
|
<strong><%= t("admin.poll_booth_assignments.show.location") %></strong>:
|
||||||
|
<%= @booth_assignment.booth.location %>
|
||||||
|
</p>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<div class="tabs-content" data-tabs-content="booths-tabs">
|
||||||
|
<ul class="tabs" data-tabs id="booths-tabs">
|
||||||
|
<li class="tabs-title is-active">
|
||||||
|
<%= link_to t("admin.poll_booth_assignments.show.officers"), "#tab-officers" %>
|
||||||
|
</li>
|
||||||
|
<li class="tabs-title">
|
||||||
|
<%= link_to t("admin.poll_booth_assignments.show.recounts"), "#tab-recounts" %>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<div class="tabs-panel is-active" id="tab-officers">
|
||||||
|
<% if @booth_assignment.officers.empty? %>
|
||||||
|
<div class="callout primary margin-top">
|
||||||
|
<%= t("admin.poll_booth_assignments.show.no_officers") %>
|
||||||
|
</div>
|
||||||
|
<% else %>
|
||||||
|
<h3><%= t("admin.poll_booth_assignments.show.officers_list") %></h3>
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<tbody>
|
||||||
|
<% @booth_assignment.officers.uniq.each do |officer| %>
|
||||||
|
<tr id="officer_<%= officer.id %>" class="officer">
|
||||||
|
<td><%= link_to officer.name, admin_officer_assignments_path(officer: officer, poll: @poll) %></td>
|
||||||
|
<td><%= officer.email %></td>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="tabs-panel" id="tab-recounts">
|
||||||
|
<% if @booth_assignment.recounts.empty? %>
|
||||||
|
<div class="callout primary margin-top">
|
||||||
|
<%= t("admin.poll_booth_assignments.show.no_recounts") %>
|
||||||
|
</div>
|
||||||
|
<% else %>
|
||||||
|
<h3><%= t("admin.poll_booth_assignments.show.recounts_list") %></h3>
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<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_system") %></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<% @booth_assignment.recounts.sort_by{|r| r.date}.each do |recount| %>
|
||||||
|
<tr id="recount_<%= recount.id %>" class="<%= 'count-error' if recount.count != 0 %>">
|
||||||
|
<td><%= l recount.date.to_date %></td>
|
||||||
|
<td class="text-center" title="<%= recount.officer_assignment.officer.name %>"><%= recount.count %></td>
|
||||||
|
<td class="text-center">0</td>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@@ -3,92 +3,10 @@
|
|||||||
<div class="clear"></div>
|
<div class="clear"></div>
|
||||||
|
|
||||||
<h2 class="inline-block">
|
<h2 class="inline-block">
|
||||||
Poll 3: <%= @booth.name %>
|
<%= @booth.name %>
|
||||||
</h2>
|
</h2>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<strong><%= t("admin.booths.show.location") %></strong>:
|
<strong><%= t("admin.booths.show.location") %></strong>:
|
||||||
<%= @booth.location %>
|
<%= @booth.location %>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div class="tabs-content" data-tabs-content="booths-tabs">
|
|
||||||
<ul class="tabs" data-tabs id="booths-tabs">
|
|
||||||
<li class="tabs-title is-active">
|
|
||||||
<%= link_to "#tab-officers" do %>
|
|
||||||
Presidentes de mesa
|
|
||||||
<% end %>
|
|
||||||
</li>
|
|
||||||
<li class="tabs-title">
|
|
||||||
<%= link_to "#tab-count" do %>
|
|
||||||
Recuentos
|
|
||||||
<% end %>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<div class="tabs-panel is-active" id="tab-officers">
|
|
||||||
<h3>Lista de presidentes de mesa</h3>
|
|
||||||
|
|
||||||
<div class="small-12 medium-6 large-4">
|
|
||||||
<select>
|
|
||||||
<option>Seleccionar fecha</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<table>
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>Fecha</th>
|
|
||||||
<th>Presidente de mesa</th>
|
|
||||||
<th>Email</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<tr>
|
|
||||||
<td>13/02/2016</td>
|
|
||||||
<td>Clemente Padilla Otero</td>
|
|
||||||
<td>user5@consul.dev</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>13/02/2016</td>
|
|
||||||
<td>Ana Luisa Ceja Benítez</td>
|
|
||||||
<td>user7@consul.dev</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>14/02/2016</td>
|
|
||||||
<td>Clemente Padilla Otero</td>
|
|
||||||
<td>user5@consul.dev</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="tabs-panel" id="tab-count">
|
|
||||||
<h3>Lista de recuentos</h3>
|
|
||||||
<table>
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>Fecha</th>
|
|
||||||
<th class="text-center">Votos (Presidente de mesa)</th>
|
|
||||||
<th class="text-center">Votos (Admin)</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<tr>
|
|
||||||
<td>13/02/2016</td>
|
|
||||||
<td class="text-center">320</td>
|
|
||||||
<td class="text-center">320</td>
|
|
||||||
</tr>
|
|
||||||
<tr class="count-error">
|
|
||||||
<td>14/02/2016</td>
|
|
||||||
<td class="text-center">160</td>
|
|
||||||
<td class="text-center">140</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>15/02/2016</td>
|
|
||||||
<td class="text-center">226</td>
|
|
||||||
<td class="text-center">226</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<h3><%= t("admin.polls.show.booths_title") %></h3>
|
<h3><%= t("admin.polls.show.booths_title") %></h3>
|
||||||
|
|
||||||
<% if @poll.booths.empty? %>
|
<% if @poll.booth_assignments.empty? %>
|
||||||
<div class="callout primary margin-top">
|
<div class="callout primary margin-top">
|
||||||
<%= t("admin.polls.show.no_booths") %>
|
<%= t("admin.polls.show.no_booths") %>
|
||||||
</div>
|
</div>
|
||||||
@@ -12,19 +12,19 @@
|
|||||||
<th class="text-center"><%= t("admin.polls.show.table_assignment") %></th>
|
<th class="text-center"><%= t("admin.polls.show.table_assignment") %></th>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<% @poll.booths.each do |booth| %>
|
<% @poll.booth_assignments.each do |booth_assignment| %>
|
||||||
<tr id="booth_<%= booth.id %>" class="booth">
|
<tr id="<%= dom_id(booth_assignment) %>" class="booth">
|
||||||
<td>
|
<td>
|
||||||
<strong>
|
<strong>
|
||||||
<%= link_to booth.name, admin_booth_path(booth) %>
|
<%= link_to booth_assignment.booth.name, admin_poll_booth_assignment_path(@poll, booth_assignment) %>
|
||||||
</strong>
|
</strong>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<%= booth.location %>
|
<%= booth_assignment.booth.location %>
|
||||||
</td>
|
</td>
|
||||||
<td class="text-center">
|
<td class="text-center">
|
||||||
<%= link_to t("admin.polls.show.remove_booth"),
|
<%= link_to t("admin.polls.show.remove_booth"),
|
||||||
admin_booth_assignment_path(poll: @poll, booth: booth),
|
admin_booth_assignment_path(booth_assignment),
|
||||||
method: :delete,
|
method: :delete,
|
||||||
class: "button hollow alert" %>
|
class: "button hollow alert" %>
|
||||||
</td>
|
</td>
|
||||||
|
|||||||
@@ -180,6 +180,18 @@ en:
|
|||||||
remove_assignment: "Remove"
|
remove_assignment: "Remove"
|
||||||
assignments: "Officing shifts in this poll"
|
assignments: "Officing shifts in this poll"
|
||||||
no_assignments: "This user has no officing shifts in this poll."
|
no_assignments: "This user has no officing shifts in this poll."
|
||||||
|
poll_booth_assignments:
|
||||||
|
show:
|
||||||
|
location: "Location"
|
||||||
|
officers: "Officers"
|
||||||
|
officers_list: "Officer list for this booth"
|
||||||
|
no_officers: "There are no officers for this booth"
|
||||||
|
recounts: "Recounts"
|
||||||
|
recounts_list: "Recount list for this booth"
|
||||||
|
no_recounts: "There are not daily recounts of this booth yet"
|
||||||
|
date: "Date"
|
||||||
|
count_by_officer: "Votes (by officer)"
|
||||||
|
count_by_system: "Votes (automatic)"
|
||||||
polls:
|
polls:
|
||||||
index:
|
index:
|
||||||
title: "List of polls"
|
title: "List of polls"
|
||||||
|
|||||||
@@ -180,6 +180,18 @@ es:
|
|||||||
remove_assignment: "Eliminar turno"
|
remove_assignment: "Eliminar turno"
|
||||||
assignments: "Turnos como presidente de mesa en esta votación"
|
assignments: "Turnos como presidente de mesa en esta votación"
|
||||||
no_assignments: "No tiene turnos como presidente de mesa en esta votación."
|
no_assignments: "No tiene turnos como presidente de mesa en esta votación."
|
||||||
|
poll_booth_assignments:
|
||||||
|
show:
|
||||||
|
location: "Ubicación"
|
||||||
|
officers: "Presidentes de mesa"
|
||||||
|
officers_list: "Lista de presidentes de mesa asignados a esta urna"
|
||||||
|
no_officers: "No hay presidentes de mesa para esta urna"
|
||||||
|
recounts: "Recuentos"
|
||||||
|
recounts_list: "Lista de recuentos de esta urna"
|
||||||
|
no_recounts: "No hay recuentos diarios de esta urna"
|
||||||
|
date: "Fecha"
|
||||||
|
count_by_officer: "Votos (presidente de mesa)"
|
||||||
|
count_by_system: "Votos (automático)"
|
||||||
polls:
|
polls:
|
||||||
index:
|
index:
|
||||||
title: "Listado de votaciones"
|
title: "Listado de votaciones"
|
||||||
|
|||||||
@@ -186,15 +186,18 @@ Rails.application.routes.draw do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scope module: :poll do
|
scope module: :poll do
|
||||||
resources :officers do
|
|
||||||
get :search, on: :collection
|
|
||||||
end
|
|
||||||
resources :polls do
|
resources :polls do
|
||||||
get :search_booths, on: :member
|
get :search_booths, on: :member
|
||||||
get :search_officers, on: :member
|
get :search_officers, on: :member
|
||||||
get :search_questions, on: :member
|
get :search_questions, on: :member
|
||||||
patch :add_question, on: :member
|
patch :add_question, on: :member
|
||||||
patch :remove_question, on: :member
|
patch :remove_question, on: :member
|
||||||
|
|
||||||
|
resources :booth_assignments, only: :show
|
||||||
|
end
|
||||||
|
|
||||||
|
resources :officers do
|
||||||
|
get :search, on: :collection
|
||||||
end
|
end
|
||||||
|
|
||||||
resources :booths
|
resources :booths
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ feature 'Admin booths assignments' do
|
|||||||
scenario 'remove booth from poll', :js do
|
scenario 'remove booth from poll', :js do
|
||||||
poll = create(:poll)
|
poll = create(:poll)
|
||||||
booth = create(:poll_booth)
|
booth = create(:poll_booth)
|
||||||
create(:poll_booth_assignment, poll: poll, booth: booth)
|
assignment = create(:poll_booth_assignment, poll: poll, booth: booth)
|
||||||
|
|
||||||
visit admin_poll_path(poll)
|
visit admin_poll_path(poll)
|
||||||
within('#poll-resources') do
|
within('#poll-resources') do
|
||||||
@@ -49,7 +49,7 @@ feature 'Admin booths assignments' do
|
|||||||
expect(page).to_not have_content 'There are no booths assigned to this poll.'
|
expect(page).to_not have_content 'There are no booths assigned to this poll.'
|
||||||
expect(page).to have_content booth.name
|
expect(page).to have_content booth.name
|
||||||
|
|
||||||
within("#booth_#{booth.id}") do
|
within("#poll_booth_assignment_#{assignment.id}") do
|
||||||
click_link 'Remove booth from poll'
|
click_link 'Remove booth from poll'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ feature 'Admin polls' do
|
|||||||
|
|
||||||
context "Poll show" do
|
context "Poll show" do
|
||||||
|
|
||||||
scenario "No booths", :js do
|
scenario "No booths" do
|
||||||
poll = create(:poll)
|
poll = create(:poll)
|
||||||
visit admin_poll_path(poll)
|
visit admin_poll_path(poll)
|
||||||
click_link "Booths (0)"
|
click_link "Booths (0)"
|
||||||
@@ -106,7 +106,7 @@ feature 'Admin polls' do
|
|||||||
expect(page).to have_content "There are no booths assigned to this poll."
|
expect(page).to have_content "There are no booths assigned to this poll."
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario "Booth list", :js do
|
scenario "Booth list" do
|
||||||
poll = create(:poll)
|
poll = create(:poll)
|
||||||
3.times { create(:poll_booth, polls: [poll]) }
|
3.times { create(:poll_booth, polls: [poll]) }
|
||||||
|
|
||||||
@@ -115,11 +115,10 @@ feature 'Admin polls' do
|
|||||||
|
|
||||||
expect(page).to have_css ".booth", count: 3
|
expect(page).to have_css ".booth", count: 3
|
||||||
|
|
||||||
booths = Poll::Booth.all
|
poll.booth_assignments.each do |ba|
|
||||||
booths.each do |booth|
|
within("#poll_booth_assignment_#{ba.id}") do
|
||||||
within("#booth_#{booth.id}") do
|
expect(page).to have_content ba.booth.name
|
||||||
expect(page).to have_content booth.name
|
expect(page).to have_content ba.booth.location
|
||||||
expect(page).to have_content booth.location
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
expect(page).to_not have_content "There are no booths assigned to this poll."
|
expect(page).to_not have_content "There are no booths assigned to this poll."
|
||||||
|
|||||||
Reference in New Issue
Block a user