Remove officing results date picker for current date
This commit is contained in:
@@ -5,7 +5,7 @@ class Officing::ResultsController < Officing::BaseController
|
||||
before_action :load_partial_results, only: :new
|
||||
|
||||
before_action :load_officer_assignment, only: :create
|
||||
before_action :check_booth_and_date, only: :create
|
||||
before_action :check_officer_assignment, only: :create
|
||||
before_action :build_results, only: :create
|
||||
|
||||
def new
|
||||
@@ -32,13 +32,9 @@ class Officing::ResultsController < Officing::BaseController
|
||||
|
||||
private
|
||||
|
||||
def check_booth_and_date
|
||||
def check_officer_assignment
|
||||
if @officer_assignment.blank?
|
||||
go_back_to_new(t("officing.results.flash.error_wrong_booth"))
|
||||
elsif results_params[:date].blank? ||
|
||||
Date.parse(results_params[:date]) < @poll.starts_at.to_date ||
|
||||
Date.parse(results_params[:date]) > @poll.ends_at.to_date
|
||||
go_back_to_new(t("officing.results.flash.error_wrong_date"))
|
||||
end
|
||||
end
|
||||
|
||||
@@ -55,7 +51,7 @@ class Officing::ResultsController < Officing::BaseController
|
||||
go_back_to_new if question.blank?
|
||||
|
||||
partial_result = ::Poll::PartialResult.find_or_initialize_by(booth_assignment_id: @officer_assignment.booth_assignment_id,
|
||||
date: results_params[:date],
|
||||
date: Date.current,
|
||||
question_id: question_id,
|
||||
answer: answer)
|
||||
partial_result.officer_assignment_id = @officer_assignment.id
|
||||
@@ -71,7 +67,7 @@ class Officing::ResultsController < Officing::BaseController
|
||||
|
||||
def build_recounts
|
||||
recount = ::Poll::Recount.find_or_initialize_by(booth_assignment_id: @officer_assignment.booth_assignment_id,
|
||||
date: results_params[:date])
|
||||
date: Date.current)
|
||||
recount.officer_assignment_id = @officer_assignment.id
|
||||
recount.author = current_user
|
||||
recount.origin = 'booth'
|
||||
@@ -84,7 +80,7 @@ class Officing::ResultsController < Officing::BaseController
|
||||
end
|
||||
|
||||
def go_back_to_new(alert = nil)
|
||||
params[:d] = results_params[:date]
|
||||
params[:d] = Date.current
|
||||
params[:oa] = results_params[:officer_assignment_id]
|
||||
flash.now[:alert] = (alert || t("officing.results.flash.error_create"))
|
||||
load_officer_assignments
|
||||
@@ -119,7 +115,7 @@ class Officing::ResultsController < Officing::BaseController
|
||||
end
|
||||
|
||||
def results_params
|
||||
params.permit(:officer_assignment_id, :date, :questions, :whites, :nulls, :total)
|
||||
params.permit(:officer_assignment_id, :questions, :whites, :nulls, :total)
|
||||
end
|
||||
|
||||
def index_params
|
||||
|
||||
@@ -12,16 +12,6 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="small-12 medium-6 column">
|
||||
<label><%= t("officing.results.new.date") %></label>
|
||||
<%= select_tag :date,
|
||||
poll_dates_select_options(@poll),
|
||||
{ prompt: t("officing.results.new.select_date"),
|
||||
label: false } %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<% @poll.questions.each do |question| %>
|
||||
<div class="row">
|
||||
<div class="small-12 column">
|
||||
@@ -101,4 +91,3 @@
|
||||
</table>
|
||||
|
||||
<% end %>
|
||||
|
||||
|
||||
@@ -21,14 +21,12 @@ en:
|
||||
create: "Results saved"
|
||||
error_create: "Results NOT saved. Error in data."
|
||||
error_wrong_booth: "Wrong booth. Results NOT saved."
|
||||
error_wrong_date: "Wrong date. Results NOT saved."
|
||||
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_white: "Totally blank ballots"
|
||||
ballots_null: "Invalid ballots"
|
||||
ballots_total: "Total ballots"
|
||||
|
||||
@@ -21,14 +21,12 @@ es:
|
||||
create: "Datos guardados"
|
||||
error_create: "Resultados NO añadidos. Error en los datos"
|
||||
error_wrong_booth: "Urna incorrecta. Resultados NO guardados."
|
||||
error_wrong_date: "Fecha incorrecta. Resultados NO guardados."
|
||||
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_white: "Papeletas totalmente en blanco"
|
||||
ballots_null: "Papeletas nulas"
|
||||
ballots_total: "Papeletas totales"
|
||||
@@ -67,4 +65,4 @@ es:
|
||||
submit: Confirmar voto
|
||||
success: "¡Voto introducido!"
|
||||
can_vote:
|
||||
submit_disable_with: "Espera, confirmando voto..."
|
||||
submit_disable_with: "Espera, confirmando voto..."
|
||||
|
||||
@@ -53,9 +53,7 @@ feature 'Officing Results' do
|
||||
expect(page).to_not have_content('Your results')
|
||||
|
||||
booth_name = @officer_assignment.booth_assignment.booth.name
|
||||
date = I18n.l(@poll.starts_at.to_date, format: :long)
|
||||
select booth_name, from: 'officer_assignment_id'
|
||||
select date, from: 'date'
|
||||
|
||||
fill_in "questions[#{@question_1.id}][0]", with: '100'
|
||||
fill_in "questions[#{@question_1.id}][1]", with: '200'
|
||||
@@ -71,8 +69,8 @@ feature 'Officing Results' do
|
||||
|
||||
expect(page).to have_content('Your results')
|
||||
|
||||
within("#results_#{@officer_assignment.booth_assignment_id}_#{@poll.starts_at.to_date.strftime('%Y%m%d')}") do
|
||||
expect(page).to have_content(date)
|
||||
within("#results_#{@officer_assignment.booth_assignment_id}_#{Date.current.strftime('%Y%m%d')}") do
|
||||
expect(page).to have_content(I18n.l(Date.current, format: :long))
|
||||
expect(page).to have_content(booth_name)
|
||||
end
|
||||
end
|
||||
@@ -81,7 +79,7 @@ feature 'Officing Results' do
|
||||
partial_result = create(:poll_partial_result,
|
||||
officer_assignment: @officer_assignment,
|
||||
booth_assignment: @officer_assignment.booth_assignment,
|
||||
date: @poll.starts_at,
|
||||
date: Date.current,
|
||||
question: @question_1,
|
||||
answer: @question_1.valid_answers[0],
|
||||
author: @poll_officer.user,
|
||||
@@ -94,9 +92,7 @@ feature 'Officing Results' do
|
||||
visit new_officing_poll_result_path(@poll)
|
||||
|
||||
booth_name = partial_result.booth_assignment.booth.name
|
||||
date = I18n.l(partial_result.date, format: :long)
|
||||
select booth_name, from: 'officer_assignment_id'
|
||||
select date, from: 'date'
|
||||
|
||||
fill_in "questions[#{@question_1.id}][0]", with: '5555'
|
||||
fill_in "questions[#{@question_1.id}][1]", with: '200'
|
||||
|
||||
Reference in New Issue
Block a user