diff --git a/app/controllers/admin/poll/booth_assignments_controller.rb b/app/controllers/admin/poll/booth_assignments_controller.rb index f09213c82..0f01ab462 100644 --- a/app/controllers/admin/poll/booth_assignments_controller.rb +++ b/app/controllers/admin/poll/booth_assignments_controller.rb @@ -1,7 +1,5 @@ class Admin::Poll::BoothAssignmentsController < Admin::BaseController - before_action :load_booth_assignment, only: :destroy - def create @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 def destroy + @booth_assignment = ::Poll::BoothAssignment.find(params[:id]) + if @booth_assignment.destroy notice = t("admin.booth_assignments.flash.destroy") 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 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 def load_booth_assignment - @booth_assignment = ::Poll::BoothAssignment.find_by(poll: params[:poll], booth: params[:booth]) + @booth_assignment = ::Poll::BoothAssignment.find(params[:id]) end def booth_assignment_params diff --git a/app/controllers/admin/poll/polls_controller.rb b/app/controllers/admin/poll/polls_controller.rb index 3e458428f..0c2e2797c 100644 --- a/app/controllers/admin/poll/polls_controller.rb +++ b/app/controllers/admin/poll/polls_controller.rb @@ -6,7 +6,7 @@ class Admin::Poll::PollsController < Admin::BaseController end 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 def new diff --git a/app/views/admin/poll/booth_assignments/show.html.erb b/app/views/admin/poll/booth_assignments/show.html.erb new file mode 100644 index 000000000..01cece32e --- /dev/null +++ b/app/views/admin/poll/booth_assignments/show.html.erb @@ -0,0 +1,73 @@ +<%= link_to admin_poll_path(@poll, anchor: 'tab-booths') do %> + + <%= @poll.name %> +<% end %> + +

<%= @booth_assignment.booth.name %>

+ +<% if @booth_assignment.booth.location.present? %> +

+ <%= t("admin.poll_booth_assignments.show.location") %>: + <%= @booth_assignment.booth.location %> +

+<% end %> + +
+ + +
+ <% if @booth_assignment.officers.empty? %> +
+ <%= t("admin.poll_booth_assignments.show.no_officers") %> +
+ <% else %> +

<%= t("admin.poll_booth_assignments.show.officers_list") %>

+ + + + <% @booth_assignment.officers.uniq.each do |officer| %> + + + + + <% end %> + +
<%= link_to officer.name, admin_officer_assignments_path(officer: officer, poll: @poll) %><%= officer.email %>
+ <% end %> +
+ +
+ <% if @booth_assignment.recounts.empty? %> +
+ <%= t("admin.poll_booth_assignments.show.no_recounts") %> +
+ <% else %> +

<%= t("admin.poll_booth_assignments.show.recounts_list") %>

+ + + + + + + + + + <% @booth_assignment.recounts.sort_by{|r| r.date}.each do |recount| %> + + + + + + <% end %> + +
<%= t("admin.poll_booth_assignments.show.date") %><%= t("admin.poll_booth_assignments.show.count_by_officer") %><%= t("admin.poll_booth_assignments.show.count_by_system") %>
<%= l recount.date.to_date %><%= recount.count %>0
+ <% end %> +
+
diff --git a/app/views/admin/poll/booths/show.html.erb b/app/views/admin/poll/booths/show.html.erb index c72fd525d..bd9355f69 100644 --- a/app/views/admin/poll/booths/show.html.erb +++ b/app/views/admin/poll/booths/show.html.erb @@ -3,92 +3,10 @@

- Poll 3: <%= @booth.name %> + <%= @booth.name %>

<%= t("admin.booths.show.location") %>: <%= @booth.location %>

- -
- - -
-

Lista de presidentes de mesa

- -
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
FechaPresidente de mesaEmail
13/02/2016Clemente Padilla Oterouser5@consul.dev
13/02/2016Ana Luisa Ceja Benítezuser7@consul.dev
14/02/2016Clemente Padilla Oterouser5@consul.dev
-
- -
-

Lista de recuentos

- - - - - - - - - - - - - - - - - - - - - - - - - -
FechaVotos (Presidente de mesa)Votos (Admin)
13/02/2016320320
14/02/2016160140
15/02/2016226226
-
-
diff --git a/app/views/admin/poll/polls/_booths.html.erb b/app/views/admin/poll/polls/_booths.html.erb index dbd5de3e1..9a70b7c63 100644 --- a/app/views/admin/poll/polls/_booths.html.erb +++ b/app/views/admin/poll/polls/_booths.html.erb @@ -1,6 +1,6 @@

<%= t("admin.polls.show.booths_title") %>

-<% if @poll.booths.empty? %> +<% if @poll.booth_assignments.empty? %>
<%= t("admin.polls.show.no_booths") %>
@@ -12,19 +12,19 @@ <%= t("admin.polls.show.table_assignment") %> - <% @poll.booths.each do |booth| %> - + <% @poll.booth_assignments.each do |booth_assignment| %> + - <%= link_to booth.name, admin_booth_path(booth) %> + <%= link_to booth_assignment.booth.name, admin_poll_booth_assignment_path(@poll, booth_assignment) %> - <%= booth.location %> + <%= booth_assignment.booth.location %> <%= link_to t("admin.polls.show.remove_booth"), - admin_booth_assignment_path(poll: @poll, booth: booth), + admin_booth_assignment_path(booth_assignment), method: :delete, class: "button hollow alert" %> diff --git a/config/locales/admin.en.yml b/config/locales/admin.en.yml index 310a9142e..3d68b02bb 100755 --- a/config/locales/admin.en.yml +++ b/config/locales/admin.en.yml @@ -180,6 +180,18 @@ en: remove_assignment: "Remove" assignments: "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: index: title: "List of polls" diff --git a/config/locales/admin.es.yml b/config/locales/admin.es.yml index a461d165e..7c93b87da 100644 --- a/config/locales/admin.es.yml +++ b/config/locales/admin.es.yml @@ -180,6 +180,18 @@ 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." + 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: index: title: "Listado de votaciones" diff --git a/config/routes.rb b/config/routes.rb index ef064513e..52d413730 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -186,15 +186,18 @@ Rails.application.routes.draw do end scope module: :poll do - resources :officers do - get :search, on: :collection - end resources :polls do get :search_booths, on: :member get :search_officers, on: :member get :search_questions, on: :member patch :add_question, on: :member patch :remove_question, on: :member + + resources :booth_assignments, only: :show + end + + resources :officers do + get :search, on: :collection end resources :booths diff --git a/spec/features/admin/poll/booth_assigments_spec.rb b/spec/features/admin/poll/booth_assigments_spec.rb index 3f21e0089..c7db2b593 100644 --- a/spec/features/admin/poll/booth_assigments_spec.rb +++ b/spec/features/admin/poll/booth_assigments_spec.rb @@ -39,7 +39,7 @@ feature 'Admin booths assignments' do scenario 'remove booth from poll', :js do poll = create(:poll) 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) 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 have_content booth.name - within("#booth_#{booth.id}") do + within("#poll_booth_assignment_#{assignment.id}") do click_link 'Remove booth from poll' end diff --git a/spec/features/admin/poll/polls_spec.rb b/spec/features/admin/poll/polls_spec.rb index 6f4f60a3d..95bf9bc9a 100644 --- a/spec/features/admin/poll/polls_spec.rb +++ b/spec/features/admin/poll/polls_spec.rb @@ -98,7 +98,7 @@ feature 'Admin polls' do context "Poll show" do - scenario "No booths", :js do + scenario "No booths" do poll = create(:poll) visit admin_poll_path(poll) 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." end - scenario "Booth list", :js do + scenario "Booth list" do poll = create(:poll) 3.times { create(:poll_booth, polls: [poll]) } @@ -115,11 +115,10 @@ feature 'Admin polls' do expect(page).to have_css ".booth", count: 3 - booths = Poll::Booth.all - booths.each do |booth| - within("#booth_#{booth.id}") do - expect(page).to have_content booth.name - expect(page).to have_content booth.location + poll.booth_assignments.each do |ba| + within("#poll_booth_assignment_#{ba.id}") do + expect(page).to have_content ba.booth.name + expect(page).to have_content ba.booth.location end end expect(page).to_not have_content "There are no booths assigned to this poll."