diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index ecb3f190f..fb79c7ae7 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -43,7 +43,6 @@ Layout/DotPosition: - 'app/controllers/admin/poll/polls_controller.rb' - 'app/controllers/admin/poll/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/results_controller.rb' - 'app/models/poll/officer.rb' @@ -193,7 +192,6 @@ Layout/MultilineMethodCallIndentation: - 'app/controllers/admin/poll/polls_controller.rb' - 'app/controllers/admin/poll/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/results_controller.rb' - 'app/models/poll/officer.rb' @@ -290,7 +288,6 @@ Lint/StringConversionInInterpolation: - 'app/models/poll/final_recount.rb' - 'app/models/poll/null_result.rb' - 'app/models/poll/partial_result.rb' - - 'app/models/poll/recount.rb' - 'app/models/poll/white_result.rb' # Offense count: 15 @@ -475,7 +472,6 @@ Style/ConditionalAssignment: - 'app/controllers/comments_controller.rb' - 'app/controllers/management/spending_proposals_controller.rb' - 'app/controllers/officing/final_recounts_controller.rb' - - 'app/controllers/officing/recounts_controller.rb' - 'app/controllers/spending_proposals_controller.rb' - 'app/controllers/verification/sms_controller.rb' - 'lib/graph_ql/api_types_creator.rb' diff --git a/app/controllers/admin/poll/booth_assignments_controller.rb b/app/controllers/admin/poll/booth_assignments_controller.rb index 4eb591d02..358f26a65 100644 --- a/app/controllers/admin/poll/booth_assignments_controller.rb +++ b/app/controllers/admin/poll/booth_assignments_controller.rb @@ -15,7 +15,7 @@ class Admin::Poll::BoothAssignmentsController < Admin::BaseController end def show - @booth_assignment = @poll.booth_assignments.includes(:recounts, :final_recounts, :voters, + @booth_assignment = @poll.booth_assignments.includes(:final_recounts, :voters, officer_assignments: [officer: [:user]]).find(params[:id]) @voters_by_date = @booth_assignment.voters.group_by {|v| v.created_at.to_date} end diff --git a/app/controllers/admin/poll/officer_assignments_controller.rb b/app/controllers/admin/poll/officer_assignments_controller.rb index 07f206f92..1f2a7ca2c 100644 --- a/app/controllers/admin/poll/officer_assignments_controller.rb +++ b/app/controllers/admin/poll/officer_assignments_controller.rb @@ -18,7 +18,7 @@ class Admin::Poll::OfficerAssignmentsController < Admin::BaseController @officer = ::Poll::Officer.includes(:user).find(officer_assignment_params[:officer_id]) @officer_assignments = ::Poll::OfficerAssignment. joins(:booth_assignment). - includes(:recount, :final_recounts, booth_assignment: :booth). + includes(:final_recounts, booth_assignment: :booth). where("officer_id = ? AND poll_booth_assignments.poll_id = ?", @officer.id, @poll.id). order(:date) end diff --git a/app/controllers/admin/poll/recounts_controller.rb b/app/controllers/admin/poll/recounts_controller.rb index fec546d79..57289a207 100644 --- a/app/controllers/admin/poll/recounts_controller.rb +++ b/app/controllers/admin/poll/recounts_controller.rb @@ -3,7 +3,7 @@ class Admin::Poll::RecountsController < Admin::BaseController def index @booth_assignments = @poll.booth_assignments. - includes(:booth, :recounts, :final_recounts, :voters). + includes(:booth, :final_recounts, :voters). order("poll_booths.name"). page(params[:page]).per(50) end @@ -13,4 +13,4 @@ class Admin::Poll::RecountsController < Admin::BaseController def load_poll @poll = ::Poll.find(params[:poll_id]) end -end \ No newline at end of file +end diff --git a/app/controllers/officing/recounts_controller.rb b/app/controllers/officing/recounts_controller.rb deleted file mode 100644 index b7ebf6acc..000000000 --- a/app/controllers/officing/recounts_controller.rb +++ /dev/null @@ -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 diff --git a/app/helpers/officing_helper.rb b/app/helpers/officing_helper.rb index 8ee97cf52..4e824b3f2 100644 --- a/app/helpers/officing_helper.rb +++ b/app/helpers/officing_helper.rb @@ -17,11 +17,6 @@ module OfficingHelper options_for_select(options, params[:oa]) 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) final_recount.booth_assignment.voters.select {|v| v.created_at.to_date == final_recount.date}.size end @@ -33,4 +28,4 @@ module OfficingHelper params[:questions][question_id.to_s][answer_index.to_s] end -end \ No newline at end of file +end diff --git a/app/helpers/poll_recounts_helper.rb b/app/helpers/poll_recounts_helper.rb index 60e3da6d7..95ea813e3 100644 --- a/app/helpers/poll_recounts_helper.rb +++ b/app/helpers/poll_recounts_helper.rb @@ -1,15 +1,7 @@ module PollRecountsHelper - def recount_for_date(recounts, date) - recounts.select {|r| r.date == date}.first - end - - def booth_assignment_sum_recounts(ba) - ba.recounts.any? ? ba.recounts.to_a.sum(&:count) : nil - end - def booth_assignment_sum_final_recounts(ba) ba.final_recounts.any? ? ba.final_recounts.to_a.sum(&:count) : nil end -end \ No newline at end of file +end diff --git a/app/models/poll/booth_assignment.rb b/app/models/poll/booth_assignment.rb index 0519fffa6..5ef9d687e 100644 --- a/app/models/poll/booth_assignment.rb +++ b/app/models/poll/booth_assignment.rb @@ -4,7 +4,6 @@ class Poll belongs_to :poll has_many :officer_assignments, class_name: "Poll::OfficerAssignment", dependent: :destroy - has_many :recounts, class_name: "Poll::Recount", dependent: :destroy has_many :final_recounts, class_name: "Poll::FinalRecount", dependent: :destroy has_many :officers, through: :officer_assignments has_many :voters diff --git a/app/models/poll/officer_assignment.rb b/app/models/poll/officer_assignment.rb index cd4f53266..1d7326500 100644 --- a/app/models/poll/officer_assignment.rb +++ b/app/models/poll/officer_assignment.rb @@ -2,7 +2,6 @@ class Poll class OfficerAssignment < ActiveRecord::Base belongs_to :officer belongs_to :booth_assignment - has_one :recount has_many :final_recounts has_many :partial_results has_many :voters diff --git a/app/models/poll/recount.rb b/app/models/poll/recount.rb deleted file mode 100644 index 57ced61fb..000000000 --- a/app/models/poll/recount.rb +++ /dev/null @@ -1,20 +0,0 @@ -class Poll - class Recount < ActiveRecord::Base - belongs_to :booth_assignment, class_name: "Poll::BoothAssignment" - belongs_to :officer_assignment, class_name: "Poll::OfficerAssignment" - - validates :booth_assignment_id, presence: true - validates :date, presence: true, uniqueness: {scope: :booth_assignment_id} - validates :officer_assignment_id, presence: true, uniqueness: {scope: :booth_assignment_id} - validates :count, presence: true, numericality: {only_integer: true} - - before_save :update_logs - - def update_logs - if count_changed? && count_was.present? - self.count_log += ":#{count_was.to_s}" - self.officer_assignment_id_log += ":#{officer_assignment_id_was.to_s}" - end - end - 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 519b36202..5b3ca41ab 100644 --- a/app/views/admin/poll/booth_assignments/show.html.erb +++ b/app/views/admin/poll/booth_assignments/show.html.erb @@ -44,44 +44,30 @@
| <%= t("admin.poll_booth_assignments.show.date") %> | -<%= t("admin.poll_booth_assignments.show.count_by_officer") %> | -<%= t("admin.poll_booth_assignments.show.count_final") %> | -<%= t("admin.poll_booth_assignments.show.count_by_system") %> | -||
|---|---|---|---|---|---|
| <%= l voting_date %> | - <% if recount.present? %> - -<%= recount.count %> | - <% else %> -- | - <% end %> - <% if final_recount.present? %> -<%= final_recount.count %> | - <% else %> -- | - <% end %> -<%= system_count %> | -
| <%= t("admin.poll_booth_assignments.show.date") %> | +<%= t("admin.poll_booth_assignments.show.count_final") %> | +<%= t("admin.poll_booth_assignments.show.count_by_system") %> | +|
|---|---|---|---|
| <%= l voting_date %> | + <% if final_recount.present? %> +<%= final_recount.count %> | + <% else %> +- | + <% end %> +<%= system_count %> | +
| <%= t("admin.poll_officer_assignments.by_officer.date") %> | -<%= t("admin.poll_officer_assignments.by_officer.booth") %> | -<%= t("admin.poll_officer_assignments.by_officer.recount") %> | -
|---|---|---|
| <%= l(officer_assignment.date.to_date) %> | -<%= booth_name_with_location(officer_assignment.booth_assignment.booth) %> | -- <% if officer_assignment.recount.present? %> - <%= officer_assignment.recount.count %> - <% else %> - - - <% end %> - | -
| <%= t("admin.recounts.index.table_booth_name") %> | -<%= t("admin.recounts.index.table_recounts") %> | <%= t("admin.recounts.index.table_final_recount") %> | <%= t("admin.recounts.index.table_system_count") %> | <% @booth_assignments.each do |booth_assignment| %> - <% recount = booth_assignment_sum_recounts(booth_assignment) %> <% final_recount = booth_assignment_sum_final_recounts(booth_assignment) %> <% system_count = booth_assignment.voters.size %>||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| - <% if recount.present? %> - <%= recount %> - <% else %> - - - <% end %> - |
<% if final_recount.present? %>
<%= final_recount %>
@@ -55,4 +46,4 @@
<%= paginate @booth_assignments %>
<% end %>
-
\ No newline at end of file
+
diff --git a/app/views/officing/_menu.html.erb b/app/views/officing/_menu.html.erb
index 2d0d93cbd..1f8c2c56d 100644
--- a/app/views/officing/_menu.html.erb
+++ b/app/views/officing/_menu.html.erb
@@ -8,13 +8,6 @@
<% end %>
- <%= t("officing.polls.index.title") %>- -<% if @polls.any? %> -
- <%= t("officing.polls.index.no_polls") %>
-
-<% end %>
\ No newline at end of file
diff --git a/app/views/officing/recounts/new.html.erb b/app/views/officing/recounts/new.html.erb
deleted file mode 100644
index dc78ccf89..000000000
--- a/app/views/officing/recounts/new.html.erb
+++ /dev/null
@@ -1,63 +0,0 @@
-<% if @officer_assignments.any? %>
- <%= t("officing.recounts.new.title", poll: @poll.name) %>- - <%= form_tag(officing_poll_recounts_path(@poll), {id: "officer_assignment_form"}) do %> - -
-
-
-
-
- <%= select_tag :officer_assignment_id,
- officer_assignments_select_options(@officer_assignments),
- { prompt: t("officing.recounts.new.select_booth_date"),
- label: false } %>
-
-
-
-
-
-
- <%= text_field_tag :count, nil, placeholder: t("officing.recounts.new.count_placeholder") %>
-
-
-
- <% end %>
-<% else %>
-
- <%= submit_tag t("officing.recounts.new.submit"), class: "button expanded" %>
-
- <%= @poll.name %>-
- <%= t("officing.recounts.new.not_allowed") %>
-
-<% end %>
-
-
-<% if @recounted.any? %>
- - <%= t("officing.recounts.new.recount_list") %>- -
|