Remove officing recount feature
This commit is contained in:
@@ -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])
|
||||
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
|
||||
end
|
||||
|
||||
@@ -8,13 +8,6 @@
|
||||
<% end %>
|
||||
</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") %>>
|
||||
<%= link_to final_officing_polls_path do %>
|
||||
<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 %>
|
||||
Reference in New Issue
Block a user