Remove officing recount feature
This commit is contained in:
@@ -43,7 +43,6 @@ Layout/DotPosition:
|
|||||||
- 'app/controllers/admin/poll/polls_controller.rb'
|
- 'app/controllers/admin/poll/polls_controller.rb'
|
||||||
- 'app/controllers/admin/poll/recounts_controller.rb'
|
- 'app/controllers/admin/poll/recounts_controller.rb'
|
||||||
- 'app/controllers/officing/final_recounts_controller.rb'
|
- 'app/controllers/officing/final_recounts_controller.rb'
|
||||||
- 'app/controllers/officing/recounts_controller.rb'
|
|
||||||
- 'app/controllers/officing/residence_controller.rb'
|
- 'app/controllers/officing/residence_controller.rb'
|
||||||
- 'app/controllers/officing/results_controller.rb'
|
- 'app/controllers/officing/results_controller.rb'
|
||||||
- 'app/models/poll/officer.rb'
|
- 'app/models/poll/officer.rb'
|
||||||
@@ -193,7 +192,6 @@ Layout/MultilineMethodCallIndentation:
|
|||||||
- 'app/controllers/admin/poll/polls_controller.rb'
|
- 'app/controllers/admin/poll/polls_controller.rb'
|
||||||
- 'app/controllers/admin/poll/recounts_controller.rb'
|
- 'app/controllers/admin/poll/recounts_controller.rb'
|
||||||
- 'app/controllers/officing/final_recounts_controller.rb'
|
- 'app/controllers/officing/final_recounts_controller.rb'
|
||||||
- 'app/controllers/officing/recounts_controller.rb'
|
|
||||||
- 'app/controllers/officing/residence_controller.rb'
|
- 'app/controllers/officing/residence_controller.rb'
|
||||||
- 'app/controllers/officing/results_controller.rb'
|
- 'app/controllers/officing/results_controller.rb'
|
||||||
- 'app/models/poll/officer.rb'
|
- 'app/models/poll/officer.rb'
|
||||||
@@ -475,7 +473,6 @@ Style/ConditionalAssignment:
|
|||||||
- 'app/controllers/comments_controller.rb'
|
- 'app/controllers/comments_controller.rb'
|
||||||
- 'app/controllers/management/spending_proposals_controller.rb'
|
- 'app/controllers/management/spending_proposals_controller.rb'
|
||||||
- 'app/controllers/officing/final_recounts_controller.rb'
|
- 'app/controllers/officing/final_recounts_controller.rb'
|
||||||
- 'app/controllers/officing/recounts_controller.rb'
|
|
||||||
- 'app/controllers/spending_proposals_controller.rb'
|
- 'app/controllers/spending_proposals_controller.rb'
|
||||||
- 'app/controllers/verification/sms_controller.rb'
|
- 'app/controllers/verification/sms_controller.rb'
|
||||||
- 'lib/graph_ql/api_types_creator.rb'
|
- 'lib/graph_ql/api_types_creator.rb'
|
||||||
|
|||||||
@@ -1,48 +0,0 @@
|
|||||||
class Officing::RecountsController < Officing::BaseController
|
|
||||||
before_action :load_poll
|
|
||||||
before_action :load_officer_assignment, only: :create
|
|
||||||
|
|
||||||
def new
|
|
||||||
@officer_assignments = ::Poll::OfficerAssignment.
|
|
||||||
includes(:recount, booth_assignment: :booth).
|
|
||||||
joins(:booth_assignment).
|
|
||||||
voting_days.
|
|
||||||
where(id: current_user.poll_officer.officer_assignment_ids).
|
|
||||||
where("poll_booth_assignments.poll_id = ?", @poll.id).
|
|
||||||
order(date: :asc)
|
|
||||||
@recounted = @officer_assignments.select {|oa| oa.recount.present?}.reverse
|
|
||||||
end
|
|
||||||
|
|
||||||
def create
|
|
||||||
@recount = ::Poll::Recount.find_or_initialize_by(booth_assignment_id: @officer_assignment.booth_assignment_id,
|
|
||||||
date: @officer_assignment.date)
|
|
||||||
@recount.officer_assignment_id = @officer_assignment.id
|
|
||||||
@recount.count = recount_params[:count]
|
|
||||||
|
|
||||||
if @recount.save
|
|
||||||
msg = { notice: t("officing.recounts.flash.create") }
|
|
||||||
else
|
|
||||||
msg = { alert: t("officing.recounts.flash.error_create") }
|
|
||||||
end
|
|
||||||
redirect_to new_officing_poll_recount_path(@poll), msg
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def load_poll
|
|
||||||
@poll = Poll.find(params[:poll_id])
|
|
||||||
end
|
|
||||||
|
|
||||||
def load_officer_assignment
|
|
||||||
@officer_assignment = current_user.poll_officer.
|
|
||||||
officer_assignments.find_by(id: recount_params[:officer_assignment_id])
|
|
||||||
if @officer_assignment.blank?
|
|
||||||
redirect_to new_officing_poll_recount_path(@poll), alert: t("officing.recounts.flash.error_create")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def recount_params
|
|
||||||
params.permit(:officer_assignment_id, :count)
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
@@ -17,11 +17,6 @@ module OfficingHelper
|
|||||||
options_for_select(options, params[:oa])
|
options_for_select(options, params[:oa])
|
||||||
end
|
end
|
||||||
|
|
||||||
def recount_to_compare_with_final_recount(final_recount)
|
|
||||||
recount = final_recount.booth_assignment.recounts.select {|r| r.date == final_recount.date}.first
|
|
||||||
recount.present? ? recount.count : "-"
|
|
||||||
end
|
|
||||||
|
|
||||||
def system_recount_to_compare_with_final_recount(final_recount)
|
def system_recount_to_compare_with_final_recount(final_recount)
|
||||||
final_recount.booth_assignment.voters.select {|v| v.created_at.to_date == final_recount.date}.size
|
final_recount.booth_assignment.voters.select {|v| v.created_at.to_date == final_recount.date}.size
|
||||||
end
|
end
|
||||||
@@ -33,4 +28,4 @@ module OfficingHelper
|
|||||||
params[:questions][question_id.to_s][answer_index.to_s]
|
params[:questions][question_id.to_s][answer_index.to_s]
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -8,13 +8,6 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
<li <%= "class=active" if ["recounts"].include?(controller_name) || (controller_name == "polls" && action_name == "index") %>>
|
|
||||||
<%= link_to officing_polls_path do %>
|
|
||||||
<span class="icon-user"></span>
|
|
||||||
<%= t("officing.menu.recounts") %>
|
|
||||||
<% end %>
|
|
||||||
</li>
|
|
||||||
|
|
||||||
<li <%= "class=active" if ["final_recounts", "results"].include?(controller_name) || (controller_name == "polls" && action_name == "final") %>>
|
<li <%= "class=active" if ["final_recounts", "results"].include?(controller_name) || (controller_name == "polls" && action_name == "final") %>>
|
||||||
<%= link_to final_officing_polls_path do %>
|
<%= link_to final_officing_polls_path do %>
|
||||||
<span class="icon-user"></span>
|
<span class="icon-user"></span>
|
||||||
|
|||||||
@@ -1,30 +0,0 @@
|
|||||||
<h2><%= t("officing.polls.index.title") %></h2>
|
|
||||||
|
|
||||||
<% if @polls.any? %>
|
|
||||||
<table>
|
|
||||||
<thead>
|
|
||||||
<th><%= t("officing.polls.index.select_poll") %></th>
|
|
||||||
<th> </th>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<% @polls.each do |poll| %>
|
|
||||||
<tr id="<%= dom_id(poll) %>" class="poll">
|
|
||||||
<td>
|
|
||||||
<strong>
|
|
||||||
<%= link_to poll.name, new_officing_poll_recount_path(poll) %>
|
|
||||||
</strong>
|
|
||||||
</td>
|
|
||||||
<td class="text-right">
|
|
||||||
<%= link_to t("officing.polls.index.add_recount"),
|
|
||||||
new_officing_poll_recount_path(poll),
|
|
||||||
class: "button hollow" %>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<% end %>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
<% else %>
|
|
||||||
<div class="callout primary">
|
|
||||||
<%= t("officing.polls.index.no_polls") %>
|
|
||||||
</div>
|
|
||||||
<% end %>
|
|
||||||
@@ -1,63 +0,0 @@
|
|||||||
<% if @officer_assignments.any? %>
|
|
||||||
<h2><%= t("officing.recounts.new.title", poll: @poll.name) %></h2>
|
|
||||||
|
|
||||||
<%= form_tag(officing_poll_recounts_path(@poll), {id: "officer_assignment_form"}) do %>
|
|
||||||
<!-- Maybe this fields pre filled and disabled? -->
|
|
||||||
<div class="row">
|
|
||||||
<div class="small-12 medium-6 column">
|
|
||||||
<label><%= t("officing.recounts.new.booth_date") %></label>
|
|
||||||
<%= select_tag :officer_assignment_id,
|
|
||||||
officer_assignments_select_options(@officer_assignments),
|
|
||||||
{ prompt: t("officing.recounts.new.select_booth_date"),
|
|
||||||
label: false } %>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="row">
|
|
||||||
<div class="small-12 medium-6 large-4 column">
|
|
||||||
<label><%= t("officing.recounts.new.count") %></label>
|
|
||||||
<%= text_field_tag :count, nil, placeholder: t("officing.recounts.new.count_placeholder") %>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="row">
|
|
||||||
<div class="small-12 medium-6 large-4 column">
|
|
||||||
<%= submit_tag t("officing.recounts.new.submit"), class: "button expanded" %>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<% end %>
|
|
||||||
<% else %>
|
|
||||||
<h2><%= @poll.name %></h2>
|
|
||||||
<div class="callout alert">
|
|
||||||
<%= t("officing.recounts.new.not_allowed") %>
|
|
||||||
</div>
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
|
|
||||||
<% if @recounted.any? %>
|
|
||||||
<hr>
|
|
||||||
<h3><%= t("officing.recounts.new.recount_list") %></h3>
|
|
||||||
|
|
||||||
<table>
|
|
||||||
<thead>
|
|
||||||
<th><%= t("officing.recounts.new.date") %></th>
|
|
||||||
<th><%= t("officing.recounts.new.booth") %></th>
|
|
||||||
<th><%= t("officing.recounts.new.count") %></th>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<% @recounted.each do |oa| %>
|
|
||||||
<tr id="<%= dom_id(oa.recount) %>">
|
|
||||||
<td>
|
|
||||||
<%= l(oa.date.to_date, format: :long) %>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<%= oa.booth_assignment.booth.name %>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<strong><%= oa.recount.count %></strong>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<% end %>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
<% end %>
|
|
||||||
@@ -9,35 +9,14 @@ en:
|
|||||||
info: Here you can validate user documents and store voting results
|
info: Here you can validate user documents and store voting results
|
||||||
menu:
|
menu:
|
||||||
voters: Validate document
|
voters: Validate document
|
||||||
recounts: Store recount
|
|
||||||
final_recounts: Final recounts and results
|
final_recounts: Final recounts and results
|
||||||
polls:
|
polls:
|
||||||
index:
|
|
||||||
title: Poll list
|
|
||||||
no_polls: You are not officing in any active poll
|
|
||||||
select_poll: Select poll
|
|
||||||
add_recount: Add recount
|
|
||||||
final:
|
final:
|
||||||
title: Polls ready for final recounting
|
title: Polls ready for final recounting
|
||||||
no_polls: You are not officing final recounts in any active poll
|
no_polls: You are not officing final recounts in any active poll
|
||||||
select_poll: Select poll
|
select_poll: Select poll
|
||||||
add_recount: Add final recount
|
add_recount: Add final recount
|
||||||
add_results: Add results
|
add_results: Add results
|
||||||
recounts:
|
|
||||||
flash:
|
|
||||||
create: "Data added"
|
|
||||||
error_create: "Count NOT added. Error in data."
|
|
||||||
new:
|
|
||||||
title: "%{poll} - Add daily recount"
|
|
||||||
not_allowed: "You are not a poll officer for this poll"
|
|
||||||
booth_date: "Booth and date"
|
|
||||||
select_booth_date: "Select booth and date"
|
|
||||||
count: "Vote count"
|
|
||||||
count_placeholder: "Vote count"
|
|
||||||
submit: Save
|
|
||||||
recount_list: "Your recounts"
|
|
||||||
booth: "Booth"
|
|
||||||
date: "Date"
|
|
||||||
final_recounts:
|
final_recounts:
|
||||||
flash:
|
flash:
|
||||||
create: "Data added"
|
create: "Data added"
|
||||||
|
|||||||
@@ -9,35 +9,14 @@ es:
|
|||||||
info: Aquí puedes validar documentos de ciudadanos y guardar los resultados de las urnas
|
info: Aquí puedes validar documentos de ciudadanos y guardar los resultados de las urnas
|
||||||
menu:
|
menu:
|
||||||
voters: "Validar documento y votar"
|
voters: "Validar documento y votar"
|
||||||
recounts: "Recuento diario"
|
|
||||||
final_recounts: "Recuento final y escrutinio"
|
final_recounts: "Recuento final y escrutinio"
|
||||||
polls:
|
polls:
|
||||||
index:
|
|
||||||
title: "Listado de votaciones"
|
|
||||||
no_polls: "No eres presidente de mesa en ninguna votación activa"
|
|
||||||
select_poll: "Selecciona votación"
|
|
||||||
add_recount: "Añadir recuento"
|
|
||||||
final:
|
final:
|
||||||
title: "Listado de votaciones finalizadas"
|
title: "Listado de votaciones finalizadas"
|
||||||
no_polls: "No tienes permiso para recuento final en ninguna votación reciente"
|
no_polls: "No tienes permiso para recuento final en ninguna votación reciente"
|
||||||
select_poll: "Selecciona votación"
|
select_poll: "Selecciona votación"
|
||||||
add_recount: "Añadir recuentos finales"
|
add_recount: "Añadir recuentos finales"
|
||||||
add_results: "Añadir resultados"
|
add_results: "Añadir resultados"
|
||||||
recounts:
|
|
||||||
flash:
|
|
||||||
create: "Datos añadidos"
|
|
||||||
error_create: "Recuento NO añadido. Error en los datos"
|
|
||||||
new:
|
|
||||||
title: "%{poll} - Añadir recuento diario"
|
|
||||||
not_allowed: "No eres presidente de mesa en esta votación"
|
|
||||||
booth_date: "Fecha y urna"
|
|
||||||
select_booth_date: "Elige fecha y urna"
|
|
||||||
count: "Número de votos"
|
|
||||||
count_placeholder: "Número de votos"
|
|
||||||
submit: "Guardar"
|
|
||||||
recount_list: "Tus recuentos"
|
|
||||||
booth: "Urna"
|
|
||||||
date: "Fecha"
|
|
||||||
final_recounts:
|
final_recounts:
|
||||||
flash:
|
flash:
|
||||||
create: "Datos añadidos"
|
create: "Datos añadidos"
|
||||||
|
|||||||
@@ -400,7 +400,6 @@ Rails.application.routes.draw do
|
|||||||
resources :polls, only: [:index] do
|
resources :polls, only: [:index] do
|
||||||
get :final, on: :collection
|
get :final, on: :collection
|
||||||
|
|
||||||
resources :recounts, only: [:new, :create]
|
|
||||||
resources :final_recounts, only: [:new, :create]
|
resources :final_recounts, only: [:new, :create]
|
||||||
resources :results, only: [:new, :create, :index]
|
resources :results, only: [:new, :create, :index]
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,87 +0,0 @@
|
|||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
feature 'Officing Recount' do
|
|
||||||
|
|
||||||
background do
|
|
||||||
@poll_officer = create(:poll_officer)
|
|
||||||
@officer_assignment = create(:poll_officer_assignment, officer: @poll_officer)
|
|
||||||
@poll = @officer_assignment.booth_assignment.poll
|
|
||||||
login_as(@poll_officer.user)
|
|
||||||
end
|
|
||||||
|
|
||||||
scenario 'Only polls where user is officer are accessible' do
|
|
||||||
not_allowed_poll = create(:poll)
|
|
||||||
|
|
||||||
visit root_path
|
|
||||||
click_link 'Polling officers'
|
|
||||||
|
|
||||||
expect(page).to have_content('Poll officing')
|
|
||||||
within('#side_menu') do
|
|
||||||
click_link 'Store recount'
|
|
||||||
end
|
|
||||||
|
|
||||||
expect(page).to_not have_content(not_allowed_poll.name)
|
|
||||||
expect(page).to have_content(@poll.name)
|
|
||||||
|
|
||||||
visit new_officing_poll_recount_path(not_allowed_poll)
|
|
||||||
expect(page).to have_content('You are not a poll officer for this poll')
|
|
||||||
end
|
|
||||||
|
|
||||||
scenario 'Add recount' do
|
|
||||||
visit officing_root_path
|
|
||||||
|
|
||||||
within('#side_menu') do
|
|
||||||
click_link 'Store recount'
|
|
||||||
end
|
|
||||||
|
|
||||||
click_link @poll.name
|
|
||||||
|
|
||||||
expect(page).to_not have_content('Your recounts')
|
|
||||||
|
|
||||||
booth_name = @officer_assignment.booth_assignment.booth.name
|
|
||||||
date = I18n.l(@officer_assignment.date.to_date, format: :long)
|
|
||||||
select "#{booth_name}: #{date}", from: 'officer_assignment_id'
|
|
||||||
fill_in :count, with: '33'
|
|
||||||
click_button 'Save'
|
|
||||||
|
|
||||||
expect(page).to have_content('Your recounts')
|
|
||||||
|
|
||||||
within("#poll_recount_#{@officer_assignment.booth_assignment.recounts.first.id}") do
|
|
||||||
expect(page).to have_content(date)
|
|
||||||
expect(page).to have_content(booth_name)
|
|
||||||
expect(page).to have_content('33')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
scenario 'Edit recount' do
|
|
||||||
recount = create(:poll_recount,
|
|
||||||
officer_assignment: @officer_assignment,
|
|
||||||
booth_assignment: @officer_assignment.booth_assignment,
|
|
||||||
date: @officer_assignment.date,
|
|
||||||
count: 100)
|
|
||||||
|
|
||||||
booth_name = @officer_assignment.booth_assignment.booth.name
|
|
||||||
date = I18n.l(@officer_assignment.date.to_date, format: :long)
|
|
||||||
|
|
||||||
visit new_officing_poll_recount_path(@poll)
|
|
||||||
|
|
||||||
expect(page).to have_content('Your recounts')
|
|
||||||
|
|
||||||
within("#poll_recount_#{recount.id}") do
|
|
||||||
expect(page).to have_content(date)
|
|
||||||
expect(page).to have_content(booth_name)
|
|
||||||
expect(page).to have_content('100')
|
|
||||||
end
|
|
||||||
|
|
||||||
select "#{booth_name}: #{date}", from: 'officer_assignment_id'
|
|
||||||
fill_in :count, with: '42'
|
|
||||||
click_button 'Save'
|
|
||||||
|
|
||||||
within("#poll_recount_#{recount.id}") do
|
|
||||||
expect(page).to have_content(date)
|
|
||||||
expect(page).to have_content(booth_name)
|
|
||||||
expect(page).to have_content('42')
|
|
||||||
end
|
|
||||||
expect(page).to_not have_content('100')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
Reference in New Issue
Block a user