diff --git a/app/controllers/admin/poll/polls_controller.rb b/app/controllers/admin/poll/polls_controller.rb index 9f5319f9d..eda5736b0 100644 --- a/app/controllers/admin/poll/polls_controller.rb +++ b/app/controllers/admin/poll/polls_controller.rb @@ -8,9 +8,7 @@ class Admin::Poll::PollsController < Admin::BaseController end def show - @poll = Poll.includes(:questions, - booth_assignments: [:final_recounts, - :recounts]). + @poll = Poll.includes(:questions). order('poll_questions.title'). find(params[:id]) end @@ -46,7 +44,7 @@ class Admin::Poll::PollsController < Admin::BaseController else notice = t("admin.polls.flash.error_on_question_added") end - redirect_to admin_poll_path(@poll, anchor: 'tab-questions'), notice: notice + redirect_to admin_poll_path(@poll), notice: notice end def remove_question @@ -58,7 +56,7 @@ class Admin::Poll::PollsController < Admin::BaseController else notice = t("admin.polls.flash.error_on_question_removed") end - redirect_to admin_poll_path(@poll, anchor: 'tab-questions'), notice: notice + redirect_to admin_poll_path(@poll), notice: notice end def search_questions diff --git a/app/controllers/admin/poll/recounts_controller.rb b/app/controllers/admin/poll/recounts_controller.rb new file mode 100644 index 000000000..6df6e8ed5 --- /dev/null +++ b/app/controllers/admin/poll/recounts_controller.rb @@ -0,0 +1,13 @@ +class Admin::Poll::RecountsController < Admin::BaseController + before_action :load_poll + + def index + @booth_assignments = @poll.booth_assignments.includes(:recounts, :final_recounts) + end + + private + + def load_poll + @poll = ::Poll.find(params[:poll_id]) + end +end \ No newline at end of file diff --git a/app/views/admin/poll/booth_assignments/show.html.erb b/app/views/admin/poll/booth_assignments/show.html.erb index d8ca6eda5..519b36202 100644 --- a/app/views/admin/poll/booth_assignments/show.html.erb +++ b/app/views/admin/poll/booth_assignments/show.html.erb @@ -34,7 +34,7 @@ <% @booth_assignment.officers.uniq.each do |officer| %> - <%= link_to officer.name, admin_officer_assignments_path(officer: officer, poll: @poll) %> + <%= link_to officer.name, by_officer_admin_poll_officer_assignments_path(@poll, officer_id: officer.id) %> <%= officer.email %> <% end %> diff --git a/app/views/admin/poll/polls/_filter_subnav.html.erb b/app/views/admin/poll/polls/_filter_subnav.html.erb index 39781de37..00c83cc0a 100644 --- a/app/views/admin/poll/polls/_filter_subnav.html.erb +++ b/app/views/admin/poll/polls/_filter_subnav.html.erb @@ -18,7 +18,7 @@ <% end %>
  • - <%= link_to "#tab-recounts" do %> + <%= link_to admin_poll_recounts_path(@poll) do %> <%= t("admin.polls.show.recounts_tab") %> <% end %>
  • diff --git a/app/views/admin/poll/polls/_recounting.html.erb b/app/views/admin/poll/polls/_recounting.html.erb deleted file mode 100644 index 8fb7651ce..000000000 --- a/app/views/admin/poll/polls/_recounting.html.erb +++ /dev/null @@ -1,40 +0,0 @@ -

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

    - -<% if @poll.booth_assignments.empty? %> -
    - <%= t("admin.polls.show.no_recounts") %> -
    -<% else %> - - - - - - - - <% @poll.booth_assignments.each do |booth_assignment| %> - - - - - - <% end %> - -
    <%= t("admin.polls.show.table_booth_name") %><%= t("admin.polls.show.table_recounts") %><%= t("admin.polls.show.table_final_recount") %>
    - - <%= link_to booth_assignment.booth.name, admin_poll_booth_assignment_path(@poll, booth_assignment, anchor: 'tab-recounts') %> - - - <% if booth_assignment.recounts.any? %> - <%= booth_assignment.recounts.to_a.sum(&:count) %> - <% else %> - - - <% end %> - - <% if booth_assignment.final_recounts.any? %> - <%= booth_assignment.final_recounts.to_a.sum(&:count) %> - <% else %> - - - <% end %> -
    -<% end %> diff --git a/app/views/admin/poll/polls/show.html.erb b/app/views/admin/poll/polls/show.html.erb index 835dd155b..9f6ef4816 100644 --- a/app/views/admin/poll/polls/show.html.erb +++ b/app/views/admin/poll/polls/show.html.erb @@ -3,14 +3,8 @@
    <%= render "filter_subnav" %> -
    - <%= render "search_questions" %> - <%= render "questions" %> -
    - -
    - <%= render 'recounting' %> -
    + <%= render "search_questions" %> + <%= render "questions" %>
    <%= render 'results' %> diff --git a/app/views/admin/poll/recounts/index.html.erb b/app/views/admin/poll/recounts/index.html.erb new file mode 100644 index 000000000..796a3efbf --- /dev/null +++ b/app/views/admin/poll/recounts/index.html.erb @@ -0,0 +1,45 @@ +<%= render "/admin/poll/polls/poll_header" %> +
    + <%= render "/admin/poll/polls/filter_subnav" %> + +

    <%= t("admin.recounts.index.title") %>

    + + <% if @booth_assignments.empty? %> +
    + <%= t("admin.recounts.index.no_recounts") %> +
    + <% else %> + + + + + + + + <% @booth_assignments.each do |booth_assignment| %> + + + + + + <% end %> + +
    <%= t("admin.recounts.index.table_booth_name") %><%= t("admin.recounts.index.table_recounts") %><%= t("admin.recounts.index.table_final_recount") %>
    + + <%= link_to booth_assignment.booth.name, admin_poll_booth_assignment_path(@poll, booth_assignment, anchor: 'tab-recounts') %> + + + <% if booth_assignment.recounts.any? %> + <%= booth_assignment.recounts.to_a.sum(&:count) %> + <% else %> + - + <% end %> + + <% if booth_assignment.final_recounts.any? %> + <%= booth_assignment.final_recounts.to_a.sum(&:count) %> + <% else %> + - + <% end %> +
    + <% end %> +
    \ No newline at end of file diff --git a/config/locales/admin.en.yml b/config/locales/admin.en.yml index fabc18019..bf51a0fe7 100755 --- a/config/locales/admin.en.yml +++ b/config/locales/admin.en.yml @@ -338,19 +338,14 @@ en: recounts_tab: Recounting results_tab: Results no_questions: "There are no questions assigned to this poll." - no_recounts: "There is nothing to be recounted" no_results: "There are no results" questions_title: "List of questions" - recounting_title: "Recounts" results_title: "Results" remove_question: "Remove question from poll" add_question: "Include question" table_title: "Title" table_assignment: "Assignment" table_name: "Name" - table_booth_name: "Booth" - table_final_recount: "Final recount (by officer)" - table_recounts: "Accumulated daily recounts (by officer)" table_whites: "Blank ballots" table_nulls: "Invalid ballots" table_answer: Answer @@ -385,6 +380,13 @@ en: valid_answers: Valid answers description: Description preview: View on website + recounts: + index: + title: "Recounts" + no_recounts: "There is nothing to be recounted" + table_booth_name: "Booth" + table_recounts: "Accumulated daily recounts (by officer)" + table_final_recount: "Final recount (by officer)" booths: index: title: "List of booths" diff --git a/config/locales/admin.es.yml b/config/locales/admin.es.yml index 5650b7ef2..f85d7cec8 100644 --- a/config/locales/admin.es.yml +++ b/config/locales/admin.es.yml @@ -338,19 +338,14 @@ es: recounts_tab: Recuentos results_tab: Resultados no_questions: "No hay preguntas asignadas a esta votación." - no_recounts: "No hay nada de lo que hacer recuento" no_results: "No hay resultados" questions_title: "Listado de preguntas asignadas" - recounting_title: "Recuentos" results_title: "Resultados" remove_question: "Desasignar pregunta" add_question: "Incluir pregunta" table_title: "Título" table_assignment: "Asignación" table_name: "Nombre" - table_booth_name: "Urna" - table_final_recount: "Recuento final (presidente de mesa)" - table_recounts: "Recuentos diarios acumulados (presidente de mesa)" table_whites: Papeletas en blanco table_nulls: Papeletas nulas table_answer: Respuesta @@ -385,6 +380,13 @@ es: valid_answers: Respuestas válidas description: Descripción preview: Ver en la web + recounts: + index: + title: "Recuentos" + no_recounts: "No hay nada de lo que hacer recuento" + table_booth_name: "Urna" + table_recounts: "Recuentos diarios acumulados (presidente de mesa)" + table_final_recount: "Recuento final (presidente de mesa)" booths: index: title: "Lista de urnas" diff --git a/config/routes.rb b/config/routes.rb index 3bcefd29a..210da83e9 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -221,6 +221,8 @@ Rails.application.routes.draw do get :search_officers, on: :collection get :by_officer, on: :collection end + + resources :recounts, only: :index end resources :officers do