diff --git a/app/controllers/officing/results_controller.rb b/app/controllers/officing/results_controller.rb
new file mode 100644
index 000000000..be6f312bf
--- /dev/null
+++ b/app/controllers/officing/results_controller.rb
@@ -0,0 +1,41 @@
+class Officing::ResultsController < Officing::BaseController
+ before_action :load_poll
+ before_action :load_officer_assignment, only: :create
+
+ def new
+ @officer_assignments = ::Poll::OfficerAssignment.
+ includes(booth_assignment: [:booth]).
+ joins(:booth_assignment).
+ final.
+ where(id: current_user.poll_officer.officer_assignment_ids).
+ where("poll_booth_assignments.poll_id = ?", @poll.id).
+ order(date: :asc)
+ end
+
+ def create
+ if false
+ notice = t("officing.results.flash.create")
+ else
+ notice = t("officing.results.flash.error_create")
+ end
+ redirect_to new_officing_poll_result_path(@poll), notice: notice
+ end
+
+ private
+ def load_poll
+ @poll = Poll.expired.includes(:questions).find(params[:poll_id])
+ end
+
+ def load_officer_assignment
+ @officer_assignment = current_user.poll_officer.
+ officer_assignments.final.find_by(id: final_recount_params[:officer_assignment_id])
+ if @officer_assignment.blank?
+ redirect_to new_officing_poll_result_path(@poll), notice: t("officing.results.flash.error_create")
+ end
+ end
+
+ def final_recount_params
+ params.permit(:officer_assignment_id, :count, :date)
+ end
+
+end
\ No newline at end of file
diff --git a/app/views/officing/results/new.html.erb b/app/views/officing/results/new.html.erb
new file mode 100644
index 000000000..0e57f640d
--- /dev/null
+++ b/app/views/officing/results/new.html.erb
@@ -0,0 +1,65 @@
+<% if @officer_assignments.any? %>
+
<%= t("officing.results.new.title", poll: @poll.name) %>
+
+ <%= form_tag(officing_poll_results_path(@poll), {id: "officer_assignment_form"}) do %>
+
+
+
+ <%= select_tag :officer_assignment_id,
+ booths_for_officer_select_options(@officer_assignments),
+ { prompt: t("officing.results.new.select_booth"),
+ label: false } %>
+
+
+
+
+
+
+ <%= select_tag :date,
+ poll_dates_select_options(@poll),
+ { prompt: t("officing.results.new.select_date"),
+ label: false } %>
+
+
+
+ <% @poll.questions.each do |question| %>
+
+
<%= question.title %>
+ <% question.valid_answers.each do |answer| %>
+
+
+ <%= text_field_tag :count, nil, placeholder: "0" %>
+
+ <% end %>
+
+
+ <% end %>
+
+
+
<%= t("officing.results.new.ballots_blank") %>
+
+ <%= text_field_tag :count, nil, placeholder: "0" %>
+
+
+
+
<%= t("officing.results.new.ballots_null") %>
+
+ <%= text_field_tag :count, nil, placeholder: "0" %>
+
+
+
+
+
+
+ <%= submit_tag t("officing.results.new.submit"), class: "button expanded" %>
+
+
+ <% end %>
+
+<% else %>
+ <%= @poll.name %>
+
+ <%= t("officing.results.new.not_allowed") %>
+
+<% end %>
+
diff --git a/config/locales/officing.en.yml b/config/locales/officing.en.yml
index c591f7b03..084ceb4ba 100644
--- a/config/locales/officing.en.yml
+++ b/config/locales/officing.en.yml
@@ -20,6 +20,7 @@ en:
no_polls: You are not officing final recounts in any active poll
select_poll: Select poll
add_recount: Add final recount
+ add_results: Add results
recounts:
flash:
create: "Data added"
@@ -51,6 +52,20 @@ en:
submit: Save
final_recount_list: "Your final recounts"
system_count: "System recount"
+ results:
+ flash:
+ create: "Results saved"
+ error_create: "Results NOT saved. Error in data."
+ new:
+ title: "%{poll} - Add results"
+ not_allowed: "You are allowed to add results for this poll"
+ booth: "Booth"
+ date: "Date"
+ select_booth: "Select booth"
+ select_date: "Select date"
+ ballots_blank: "Blank ballots"
+ ballots_null: "Invalid ballots"
+ submit: "Save"
residence:
flash:
create: "Document verified with Census"
diff --git a/config/locales/officing.es.yml b/config/locales/officing.es.yml
index 9de110454..56d6f745f 100644
--- a/config/locales/officing.es.yml
+++ b/config/locales/officing.es.yml
@@ -20,6 +20,7 @@ es:
no_polls: "No tienes permiso para recuento final en ninguna votación reciente"
select_poll: "Selecciona votación"
add_recount: "Añadir recuentos finales"
+ add_results: "Añadir resultados"
recounts:
flash:
create: "Datos añadidos"
@@ -51,6 +52,20 @@ es:
submit: "Guardar"
final_recount_list: "Tus recuentos finales"
system_count: "Recuento del sistema"
+ results:
+ flash:
+ create: "Datos guardados"
+ error_create: "Resultados NO añadidos. Error en los datos"
+ new:
+ title: "%{poll} - Añadir resultados"
+ not_allowed: "No tienes permiso para introducir resultados"
+ booth: "Urna"
+ date: "Día"
+ select_booth: "Elige urna"
+ select_date: "Elige día"
+ ballots_blank: "Papeletas en blanco"
+ ballots_null: "Papeletas nulas"
+ submit: "Guardar"
residence:
flash:
create: "Documento verificado con el Padrón"
diff --git a/config/routes.rb b/config/routes.rb
index 8be55feb5..2295453b6 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -336,6 +336,7 @@ Rails.application.routes.draw do
resources :recounts, only: [:new, :create]
resources :final_recounts, only: [:new, :create]
+ resources :results, only: [:new, :create]
end
resource :residence, controller: "residence", only: [:new, :create]
resources :voters, only: [:new, :create]