Remove final result usage on admin poll officer assignments results

This commit is contained in:
Bertocq
2017-09-19 01:13:01 +02:00
parent 1c1bb7bf38
commit a3bf69e78d
15 changed files with 26 additions and 59 deletions

View File

@@ -15,7 +15,7 @@ class Admin::Poll::BoothAssignmentsController < Admin::BaseController
end
def show
@booth_assignment = @poll.booth_assignments.includes(:final_recounts, :voters,
@booth_assignment = @poll.booth_assignments.includes(:total_results, :voters,
officer_assignments: [officer: [:user]]).find(params[:id])
@voters_by_date = @booth_assignment.voters.group_by {|v| v.created_at.to_date}
end

View File

@@ -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(:final_recounts, booth_assignment: :booth).
includes(:total_results, booth_assignment: :booth).
where("officer_id = ? AND poll_booth_assignments.poll_id = ?", @officer.id, @poll.id).
order(:date)
end

View File

@@ -3,7 +3,7 @@ class Admin::Poll::RecountsController < Admin::BaseController
def index
@booth_assignments = @poll.booth_assignments.
includes(:booth, :final_recounts, :voters).
includes(:booth, :total_results, :voters).
order("poll_booths.name").
page(params[:page]).per(50)
end

View File

@@ -4,7 +4,6 @@ class Poll
belongs_to :poll
has_many :officer_assignments, class_name: "Poll::OfficerAssignment", dependent: :destroy
has_many :final_recounts, class_name: "Poll::FinalRecount", dependent: :destroy
has_many :officers, through: :officer_assignments
has_many :voters
has_many :partial_results

View File

@@ -2,8 +2,10 @@ class Poll
class OfficerAssignment < ActiveRecord::Base
belongs_to :officer
belongs_to :booth_assignment
has_many :final_recounts
has_many :partial_results
has_many :white_results
has_many :null_results
has_many :total_results
has_many :voters
validates :officer_id, presence: true

View File

@@ -31,23 +31,23 @@
<% final_officer_assignments = @officer_assignments.select{|oa| oa.final == true} %>
<% if final_officer_assignments.any? %>
<h3><%= t("admin.poll_officer_assignments.by_officer.final_recounts") %></h3>
<table id="final_recount_list" class="fixed">
<h3><%= t("admin.poll_officer_assignments.by_officer.total_recounts") %></h3>
<table id="total_recount_list" class="fixed">
<thead>
<tr>
<th><%= t("admin.poll_officer_assignments.by_officer.date") %></th>
<th><%= t("admin.poll_officer_assignments.by_officer.booth") %></th>
<th class="text-right"><%= t("admin.poll_officer_assignments.by_officer.final_recount") %></th>
<th class="text-right"><%= t("admin.poll_officer_assignments.by_officer.total_recount") %></th>
</tr>
</thead>
<tbody>
<% final_officer_assignments.each do |officer_assignment| %>
<tr id="final_recount_<%= officer_assignment.date.to_date.strftime('%Y%m%d') %>">
<tr id="total_recount_<%= officer_assignment.date.to_date.strftime('%Y%m%d') %>">
<td><%= l(officer_assignment.date.to_date) %></td>
<td><%= booth_name_with_location(officer_assignment.booth_assignment.booth) %></td>
<td class="text-right">
<% if officer_assignment.final_recounts.any? %>
<%= officer_assignment.final_recounts.to_a.sum(&:count) %>
<% if officer_assignment.total_recounts.any? %>
<%= officer_assignment.total_recounts.to_a.sum(&:amount) %>
<% else %>
<span>-</span>
<% end %>

View File

@@ -8,10 +8,10 @@
<% end %>
</li>
<li <%= "class=active" if ["final_recounts", "results"].include?(controller_name) || (controller_name == "polls" && action_name == "final") %>>
<li <%= "class=active" if ["results"].include?(controller_name) || (controller_name == "polls" && action_name == "final") %>>
<%= link_to final_officing_polls_path do %>
<span class="icon-user"></span>
<%= t("officing.menu.final_recounts") %>
<%= t("officing.menu.total_recounts") %>
<% end %>
</li>
</ul>