From b5255afb2dbac6e8e62a3c60406a15961ec737dc Mon Sep 17 00:00:00 2001 From: Bertocq Date: Wed, 18 Oct 2017 00:17:01 +0200 Subject: [PATCH 01/25] Remove deprecated Poll::Question valid_answers attribute --- .../20171017221546_remove_poll_question_valid_answers.rb | 5 +++++ db/schema.rb | 3 +-- 2 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 db/migrate/20171017221546_remove_poll_question_valid_answers.rb diff --git a/db/migrate/20171017221546_remove_poll_question_valid_answers.rb b/db/migrate/20171017221546_remove_poll_question_valid_answers.rb new file mode 100644 index 000000000..e4c1ebb11 --- /dev/null +++ b/db/migrate/20171017221546_remove_poll_question_valid_answers.rb @@ -0,0 +1,5 @@ +class RemovePollQuestionValidAnswers < ActiveRecord::Migration + def change + remove_column :poll_questions, :valid_answers + end +end diff --git a/db/schema.rb b/db/schema.rb index 8a03412be..c3ccbeac7 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20171010143623) do +ActiveRecord::Schema.define(version: 20171017221546) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -676,7 +676,6 @@ ActiveRecord::Schema.define(version: 20171010143623) do t.integer "author_id" t.string "author_visible_name" t.string "title" - t.string "valid_answers" t.integer "comments_count" t.datetime "hidden_at" t.datetime "created_at" From 05a713790f4f0cf41c08fd3185da3f8300ee8971 Mon Sep 17 00:00:00 2001 From: decabeza Date: Wed, 18 Oct 2017 18:54:01 +0200 Subject: [PATCH 02/25] improves edit debate button on debate show --- app/assets/stylesheets/participation.scss | 4 ---- app/views/debates/show.html.erb | 16 +++++++++------- config/locales/en/general.yml | 1 + config/locales/es/general.yml | 1 + 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/app/assets/stylesheets/participation.scss b/app/assets/stylesheets/participation.scss index a887d83de..55645309f 100644 --- a/app/assets/stylesheets/participation.scss +++ b/app/assets/stylesheets/participation.scss @@ -363,10 +363,6 @@ width: rem-calc(48); } - .edit-debate { - margin-bottom: 0; - } - .debate-info, .proposal-info, .investment-project-info, diff --git a/app/views/debates/show.html.erb b/app/views/debates/show.html.erb index 44fa08a06..5f6d6b50f 100644 --- a/app/views/debates/show.html.erb +++ b/app/views/debates/show.html.erb @@ -9,13 +9,6 @@
<%= back_link_to %> - <% if current_user && @debate.editable_by?(current_user) %> - <%= link_to edit_debate_path(@debate), class: 'edit-debate button success small float-right' do %> - - <%= t("debates.show.edit_debate_link") %> - <% end %> - <% end %> -

<%= @debate.title %>

<% if @debate.conflictive? %>
@@ -47,6 +40,15 @@
\ No newline at end of file + diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index e4085c8e5..4e6b6f0e5 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -43,7 +43,9 @@ <%= render "activity_page" %> <% else %> -

<%= t('users.show.private_activity') %>

+
+ <%= t('users.show.private_activity') %> +
<% end %> <%= render 'interests', user: @user if valid_interests_access? %> diff --git a/config/locales/en/general.yml b/config/locales/en/general.yml index d42a24ac9..172c8e2bf 100644 --- a/config/locales/en/general.yml +++ b/config/locales/en/general.yml @@ -14,8 +14,8 @@ en: phone_number_label: Phone number public_activity_label: Keep my list of activities public public_interests_label: Keep my interests public - public_interests_my_title_list: List of interests (Tags of elements you follow) - public_interests_user_title_list: List of interests (Tags of elements this user follows) + public_interests_my_title_list: List of interests (tags of elements you follow) + public_interests_user_title_list: List of interests (tags of elements this user follows) public_interests_my_empty_list: You do not follow any elements yet. public_interests_user_empty_list: This user does not follow any elements yet. save_changes_submit: Save changes @@ -731,7 +731,7 @@ en: other: "%{count} Following" no_activity: User has no public activity no_private_messages: "This user doesn't accept private messages." - private_activity: This user decided to keep the activity list private + private_activity: This user decided to keep the activity list private. send_private_message: "Send private message" proposals: send_notification: "Send notification" diff --git a/config/locales/es/general.yml b/config/locales/es/general.yml index 05c810a76..e56f725c9 100644 --- a/config/locales/es/general.yml +++ b/config/locales/es/general.yml @@ -14,8 +14,8 @@ es: phone_number_label: Teléfono public_activity_label: Mostrar públicamente mi lista de actividades public_interests_label: Mostrar públicamente mis intereses - public_interests_my_title_list: Lista de intereses (Etiquetas de los elementos que sigues) - public_interests_user_title_list: Lista de intereses (Etiquetas de los elementos seguidos este usuario) + public_interests_my_title_list: Lista de intereses (etiquetas de los elementos que sigues) + public_interests_user_title_list: Lista de intereses (etiquetas de los elementos seguidos este usuario) public_interests_my_empty_list: Aún no sigues ningún elemento. public_interests_user_empty_list: Este usuario no sigue ningún elemento todavía. save_changes_submit: Guardar cambios @@ -731,7 +731,7 @@ es: other: "%{count} Siguiendo" no_activity: Usuario sin actividad pública no_private_messages: "Este usuario no acepta mensajes privados." - private_activity: Este usuario ha decidido mantener en privado su lista de actividades + private_activity: Este usuario ha decidido mantener en privado su lista de actividades. send_private_message: "Enviar un mensaje privado" proposals: send_notification: "Enviar notificación" From 2148ee7492cd6026bd723e5b2554799b2ff7d7a0 Mon Sep 17 00:00:00 2001 From: decabeza Date: Wed, 18 Oct 2017 19:37:20 +0200 Subject: [PATCH 06/25] updates texts on specs --- spec/features/users_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/features/users_spec.rb b/spec/features/users_spec.rb index ae2bac6d1..5a73209df 100644 --- a/spec/features/users_spec.rb +++ b/spec/features/users_spec.rb @@ -314,7 +314,7 @@ feature 'Users' do @user.update(public_interests: true) visit user_path(@user) - expect(page).to have_content("List of interests (Tags of elements this user follows)") + expect(page).to have_content("List of interests (tags of elements this user follows)") end scenario 'Should display custom interests title when user is visiting own user page' do @@ -322,7 +322,7 @@ feature 'Users' do login_as(@user) visit user_path(@user) - expect(page).to have_content("List of interests (Tags of elements you follow)") + expect(page).to have_content("List of interests (tags of elements you follow)") end scenario 'Should display generic empty interests list message when visited user has not interests defined' do From d15f150e988af033df5c57aa3cb8b7f857faeb1e Mon Sep 17 00:00:00 2001 From: Bertocq Date: Wed, 18 Oct 2017 20:49:30 +0200 Subject: [PATCH 07/25] Trim officer shifts by booth as well --- app/helpers/shifts_helper.rb | 20 ++++++++++---------- app/views/admin/poll/shifts/_form.html.erb | 4 ++-- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/app/helpers/shifts_helper.rb b/app/helpers/shifts_helper.rb index 3773014ac..3a55feb4f 100644 --- a/app/helpers/shifts_helper.rb +++ b/app/helpers/shifts_helper.rb @@ -1,23 +1,23 @@ module ShiftsHelper - def shift_vote_collection_dates(polls) - date_options((start_date(polls)..end_date(polls)), Poll::Shift.tasks[:vote_collection]) + def shift_vote_collection_dates(booth, polls) + date_options((start_date(polls)..end_date(polls)), Poll::Shift.tasks[:vote_collection], booth) end - def shift_recount_scrutiny_dates(polls) + def shift_recount_scrutiny_dates(booth, polls) dates = polls.map(&:ends_at).map(&:to_date).sort.inject([]) do |total, date| initial_date = date < Date.current ? Date.current : date total << (initial_date..date + Poll::RECOUNT_DURATION).to_a end - date_options(dates.flatten.uniq, Poll::Shift.tasks[:recount_scrutiny]) + date_options(dates.flatten.uniq, Poll::Shift.tasks[:recount_scrutiny], booth) end - def date_options(dates, task_id) - valid_dates(dates, task_id).map { |date| [l(date, format: :long), l(date)] } + def date_options(dates, task_id, booth) + valid_dates(dates, task_id, booth).map { |date| [l(date, format: :long), l(date)] } end - def valid_dates(dates, task_id) - dates.reject { |date| officer_shifts(task_id).include?(date) } + def valid_dates(dates, task_id, booth) + dates.reject { |date| officer_shifts(task_id, booth).include?(date) } end def start_date(polls) @@ -35,7 +35,7 @@ module ShiftsHelper private - def officer_shifts(task_id) - @officer.shifts.where(task: task_id).map(&:date) + def officer_shifts(task_id, booth) + @officer.shifts.where(task: task_id, booth: booth).map(&:date) end end diff --git a/app/views/admin/poll/shifts/_form.html.erb b/app/views/admin/poll/shifts/_form.html.erb index 4004a949b..07e07381f 100644 --- a/app/views/admin/poll/shifts/_form.html.erb +++ b/app/views/admin/poll/shifts/_form.html.erb @@ -24,12 +24,12 @@
<%= select 'shift[date]', 'vote_collection_date', - options_for_select(shift_vote_collection_dates(@booth.polls.current_or_incoming)), + options_for_select(shift_vote_collection_dates(@booth, @booth.polls.current_or_incoming)), { prompt: t("admin.poll_shifts.new.select_date"), label: false }, class: 'js-shift-vote-collection-dates' %> <%= select 'shift[date]', 'recount_scrutiny_date', - options_for_select(shift_recount_scrutiny_dates(@booth.polls.current_or_recounting_or_incoming)), + options_for_select(shift_recount_scrutiny_dates(@booth, @booth.polls.current_or_recounting_or_incoming)), { prompt: t("admin.poll_shifts.new.select_date"), label: false }, class: 'js-shift-recount-scrutiny-dates', From df9fb607a7ccf2ac81fa26bbcfb17433372543f5 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Thu, 19 Oct 2017 00:49:45 +0200 Subject: [PATCH 08/25] Fix delete budget investment translation on english --- config/locales/en/general.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/locales/en/general.yml b/config/locales/en/general.yml index 172c8e2bf..9c16e40ec 100644 --- a/config/locales/en/general.yml +++ b/config/locales/en/general.yml @@ -707,7 +707,7 @@ en: deleted: Deleted deleted_debate: This debate has been deleted deleted_proposal: This proposal has been deleted - deleted_budget_investment: This investment has been deleted + deleted_budget_investment: This investment project has been deleted proposals: Proposals debates: Debates budget_investments: Budget investments From 3d43bc922b9bff2fbd061d4d25692f8905f4045f Mon Sep 17 00:00:00 2001 From: decabeza Date: Thu, 19 Oct 2017 10:19:42 +0200 Subject: [PATCH 09/25] replaces citizen question to polls question i18n on admin --- config/locales/es/admin.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config/locales/es/admin.yml b/config/locales/es/admin.yml index d1a24b314..0aa73ffb2 100644 --- a/config/locales/es/admin.yml +++ b/config/locales/es/admin.yml @@ -405,7 +405,7 @@ es: admin: Menú de administración banner: Gestionar banners proposals_topics: Temas de propuestas - poll_questions: Preguntas ciudadanas + poll_questions: Preguntas de votaciones budgets: Presupuestos participativos geozones: Gestionar distritos hidden_comments: Comentarios ocultos @@ -577,12 +577,12 @@ es: error_on_question_added: "No se pudo asignar la pregunta" questions: index: - title: "Preguntas ciudadanas" + title: "Preguntas de votaciones" create: "Crear pregunta ciudadana" no_questions: "No hay ninguna pregunta ciudadana." filter_poll: "Filtrar por votación" select_poll: "Seleccionar votación" - questions_tab: "Preguntas ciudadanas" + questions_tab: "Preguntas" successful_proposals_tab: "Propuestas que han superado el umbral" create_question: "Crear pregunta para votación" table_proposal: "Propuesta" From cd148dfbf09658940394b77e4178740e5212fb90 Mon Sep 17 00:00:00 2001 From: rgarcia Date: Wed, 18 Oct 2017 18:44:24 +0200 Subject: [PATCH 10/25] adds recounts and results to dev seeds --- db/dev_seeds.rb | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/db/dev_seeds.rb b/db/dev_seeds.rb index 18bfe0dcb..8c09923d8 100644 --- a/db/dev_seeds.rb +++ b/db/dev_seeds.rb @@ -640,6 +640,49 @@ print "Creating Poll Voters" Poll::Voter.create(poll: poll, user: user) end +puts " ✅" +print "Creating Poll Recounts" + +Poll.all.each do |poll| + poll.booth_assignments.each do |booth_assignment| + officer_assignment = poll.officer_assignments.first + author = Poll::Officer.first.user + + Poll::Recount.create!(officer_assignment: officer_assignment, + booth_assignment: booth_assignment, + author: author, + date: poll.ends_at, + white_amount: rand(0..10), + null_amount: rand(0..10), + total_amount: rand(100..9999), + origin: "booth") + end +end + +puts " ✅" +print "Creating Poll Results" + +Poll.all.each do |poll| + poll.booth_assignments.each do |booth_assignment| + officer_assignment = poll.officer_assignments.first + author = Poll::Officer.first.user + + poll.questions.each do |question| + question.question_answers.each do |answer| + Poll::PartialResult.create!(officer_assignment: officer_assignment, + booth_assignment: booth_assignment, + date: Date.current, + question: question, + answer: answer.title, + author: author, + amount: rand(999), + origin: "booth") + end + end + end + +end + puts " ✅" print "Creating legislation processes" From cf400f3082836c884ca79318437637e20bf4c2e0 Mon Sep 17 00:00:00 2001 From: rgarcia Date: Wed, 18 Oct 2017 20:18:56 +0200 Subject: [PATCH 11/25] refactors poll results into partial --- app/views/admin/poll/results/_result.html.erb | 37 +++++++++++++++++ app/views/admin/poll/results/index.html.erb | 40 +------------------ 2 files changed, 38 insertions(+), 39 deletions(-) create mode 100644 app/views/admin/poll/results/_result.html.erb diff --git a/app/views/admin/poll/results/_result.html.erb b/app/views/admin/poll/results/_result.html.erb new file mode 100644 index 000000000..074c26ebf --- /dev/null +++ b/app/views/admin/poll/results/_result.html.erb @@ -0,0 +1,37 @@ + + + + + + + + + + + + + +
<%= t("admin.results.index.table_whites") %><%= t("admin.results.index.table_nulls") %><%= t("admin.results.index.table_total") %>
<%= @poll.recounts.sum(:white_amount) %><%= @poll.recounts.sum(:null_amount) %><%= @poll.recounts.sum(:total_amount) %>
+ + +<% by_question = @partial_results.group_by(&:question_id) %> +<% @poll.questions.each do |question| %> +

<%= question.title %>

+ + + + + + + + + <% question.question_answers.each_with_index do |answer, i| %> + <% by_answer = by_question[question.id].present? ? by_question[question.id].group_by(&:answer) : {} %> + + + + + <% end %> + +
<%= t("admin.results.index.table_answer") %><%= t("admin.results.index.table_votes") %>
<%= answer.title %><%= by_answer[answer.title].present? ? by_answer[answer.title].sum(&:amount) : 0 %>
+<% end %> \ No newline at end of file diff --git a/app/views/admin/poll/results/index.html.erb b/app/views/admin/poll/results/index.html.erb index ab4e94857..e80a20f2b 100644 --- a/app/views/admin/poll/results/index.html.erb +++ b/app/views/admin/poll/results/index.html.erb @@ -9,44 +9,6 @@ <%= t("admin.results.index.no_results") %>
<% else %> - - - - - - - - - - - - - - -
<%= t("admin.results.index.table_whites") %><%= t("admin.results.index.table_nulls") %><%= t("admin.results.index.table_total") %>
<%= @poll.recounts.sum(:white_amount) %><%= @poll.recounts.sum(:null_amount) %><%= @poll.recounts.sum(:total_amount) %>
- - - <% by_question = @partial_results.group_by(&:question_id) %> - <% @poll.questions.each do |question| %> -

<%= question.title %>

- - - - - - - - - <% question.question_answers.each_with_index do |answer, i| %> - <% by_answer = by_question[question.id].present? ? by_question[question.id].group_by(&:answer) : {} %> - - - - - <% end %> - -
<%= t("admin.results.index.table_answer") %><%= t("admin.results.index.table_votes") %>
<%= answer.title %><%= by_answer[answer.title].present? ? by_answer[answer.title].sum(&:amount) : 0 %>
- <% end %> - + <%= render "result" %> <% end %> From 34ee16a1c191179c5be4847788263e5256cf989a Mon Sep 17 00:00:00 2001 From: rgarcia Date: Wed, 18 Oct 2017 20:25:36 +0200 Subject: [PATCH 12/25] displays results for booth --- .../admin/poll/booth_assignments_controller.rb | 1 + .../poll/booth_assignments/_results.html.erb | 11 +++++++++++ .../admin/poll/booth_assignments/show.html.erb | 18 ++++++++++++++---- 3 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 app/views/admin/poll/booth_assignments/_results.html.erb diff --git a/app/controllers/admin/poll/booth_assignments_controller.rb b/app/controllers/admin/poll/booth_assignments_controller.rb index 8ffa455c8..c9f95de30 100644 --- a/app/controllers/admin/poll/booth_assignments_controller.rb +++ b/app/controllers/admin/poll/booth_assignments_controller.rb @@ -18,6 +18,7 @@ class Admin::Poll::BoothAssignmentsController < Admin::Poll::BaseController @booth_assignment = @poll.booth_assignments.includes(:recounts, :voters, officer_assignments: [officer: [:user]]).find(params[:id]) @voters_by_date = @booth_assignment.voters.group_by {|v| v.created_at.to_date} + @partial_results = @booth_assignment.partial_results end def create diff --git a/app/views/admin/poll/booth_assignments/_results.html.erb b/app/views/admin/poll/booth_assignments/_results.html.erb new file mode 100644 index 000000000..224da76ab --- /dev/null +++ b/app/views/admin/poll/booth_assignments/_results.html.erb @@ -0,0 +1,11 @@ +
+

<%= t("admin.results.index.title") %>

+ + <% if @partial_results.empty? %> +
+ <%= t("admin.results.index.no_results") %> +
+ <% else %> + <%= render "admin/poll/results/result" %> + <% 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 fd303d099..5f80f2617 100644 --- a/app/views/admin/poll/booth_assignments/show.html.erb +++ b/app/views/admin/poll/booth_assignments/show.html.erb @@ -17,9 +17,12 @@
  • <%= link_to t("admin.poll_booth_assignments.show.officers"), "#tab-officers" %>
  • -
  • +
  • <%= link_to t("admin.poll_booth_assignments.show.recounts"), "#tab-recounts" %>
  • +
  • + <%= link_to "Results", "#tab-results" %> +
  • @@ -43,7 +46,7 @@ <% end %>
    -
    +

    <%= t("admin.poll_booth_assignments.show.recounts_list") %>

    @@ -55,8 +58,12 @@ - - + +
    <%= total_recounts_by_booth(@booth_assignment) || '-' %><%= @booth_assignment.voters.count %> + <%= total_recounts_by_booth(@booth_assignment) || '-' %> + + <%= @booth_assignment.voters.count %> +
    @@ -79,4 +86,7 @@
    +
    + <%= render "results" %> +
    From 6b98bc0086991abaf63f274e8a4136381d2b0ae3 Mon Sep 17 00:00:00 2001 From: rgarcia Date: Wed, 18 Oct 2017 20:25:54 +0200 Subject: [PATCH 13/25] displays links to results by booth --- .../poll/results/_results_by_booth.html.erb | 19 +++++++++++++++++++ app/views/admin/poll/results/index.html.erb | 1 + 2 files changed, 20 insertions(+) create mode 100644 app/views/admin/poll/results/_results_by_booth.html.erb diff --git a/app/views/admin/poll/results/_results_by_booth.html.erb b/app/views/admin/poll/results/_results_by_booth.html.erb new file mode 100644 index 000000000..3c240f8d3 --- /dev/null +++ b/app/views/admin/poll/results/_results_by_booth.html.erb @@ -0,0 +1,19 @@ + + + + + + + + + <% @poll.booth_assignments.each do |booth_assignment| %> + + + + + <% end %> + +
    UrnaResultados
    <%= booth_assignment.booth.name %> + <%= link_to "See results", + admin_poll_booth_assignment_path(@poll, booth_assignment, anchor: "tab-results") %> +
    \ No newline at end of file diff --git a/app/views/admin/poll/results/index.html.erb b/app/views/admin/poll/results/index.html.erb index e80a20f2b..f4823ccd4 100644 --- a/app/views/admin/poll/results/index.html.erb +++ b/app/views/admin/poll/results/index.html.erb @@ -10,5 +10,6 @@ <% else %> <%= render "result" %> + <%= render "results_by_booth" %> <% end %> From 0e8dc55b1be09ea64e1832e0894dceb755fa1af4 Mon Sep 17 00:00:00 2001 From: rgarcia Date: Wed, 18 Oct 2017 20:46:31 +0200 Subject: [PATCH 14/25] updates translations --- app/views/admin/poll/booth_assignments/show.html.erb | 2 +- app/views/admin/poll/results/_result.html.erb | 10 +++++----- .../admin/poll/results/_results_by_booth.html.erb | 9 +++++---- config/locales/en/admin.yml | 6 ++++++ config/locales/es/admin.yml | 6 ++++++ 5 files changed, 23 insertions(+), 10 deletions(-) diff --git a/app/views/admin/poll/booth_assignments/show.html.erb b/app/views/admin/poll/booth_assignments/show.html.erb index 5f80f2617..c69631dee 100644 --- a/app/views/admin/poll/booth_assignments/show.html.erb +++ b/app/views/admin/poll/booth_assignments/show.html.erb @@ -21,7 +21,7 @@ <%= link_to t("admin.poll_booth_assignments.show.recounts"), "#tab-recounts" %>
  • - <%= link_to "Results", "#tab-results" %> + <%= link_to t("admin.poll_booth_assignments.show.results"), "#tab-results" %>
  • diff --git a/app/views/admin/poll/results/_result.html.erb b/app/views/admin/poll/results/_result.html.erb index 074c26ebf..64da2c9b2 100644 --- a/app/views/admin/poll/results/_result.html.erb +++ b/app/views/admin/poll/results/_result.html.erb @@ -1,8 +1,8 @@ - - - + + + @@ -20,8 +20,8 @@
    <%= t("admin.results.index.table_whites") %><%= t("admin.results.index.table_nulls") %><%= t("admin.results.index.table_total") %><%= t("admin.results.result.table_whites") %><%= t("admin.results.result.table_nulls") %><%= t("admin.results.result.table_total") %>
    - - + + diff --git a/app/views/admin/poll/results/_results_by_booth.html.erb b/app/views/admin/poll/results/_results_by_booth.html.erb index 3c240f8d3..8778a7434 100644 --- a/app/views/admin/poll/results/_results_by_booth.html.erb +++ b/app/views/admin/poll/results/_results_by_booth.html.erb @@ -1,8 +1,8 @@
    <%= t("admin.results.index.table_answer") %><%= t("admin.results.index.table_votes") %><%= t("admin.results.result.table_answer") %><%= t("admin.results.result.table_votes") %>
    - - + + @@ -10,8 +10,9 @@ <% end %> diff --git a/config/locales/en/admin.yml b/config/locales/en/admin.yml index 87bbb6685..2b6f2988e 100644 --- a/config/locales/en/admin.yml +++ b/config/locales/en/admin.yml @@ -537,6 +537,7 @@ en: no_officers: "There are no officers for this booth" recounts: "Recounts" recounts_list: "Recount list for this booth" + results: "Results" date: "Date" count_final: "Final recount (by officer)" count_by_system: "Votes (automatic)" @@ -647,11 +648,16 @@ en: index: title: "Results" no_results: "There are no results" + result: table_whites: "Totally blank ballots" table_nulls: "Invalid ballots" table_total: "Total ballots" table_answer: Answer table_votes: Votes + results_by_booth: + booth: Booth + results: Results + see_results: See results booths: index: title: "List of booths" diff --git a/config/locales/es/admin.yml b/config/locales/es/admin.yml index 0aa73ffb2..26e2d18dc 100644 --- a/config/locales/es/admin.yml +++ b/config/locales/es/admin.yml @@ -537,6 +537,7 @@ es: no_officers: "No hay presidentes de mesa para esta urna" recounts: "Recuentos" recounts_list: "Lista de recuentos de esta urna" + results: "Resultados" date: "Fecha" count_final: "Recuento final (presidente de mesa)" count_by_system: "Votos (automático)" @@ -649,11 +650,16 @@ es: index: title: "Resultados" no_results: "No hay resultados" + result: table_whites: Papeletas totalmente en blanco table_nulls: Papeletas nulas table_total: Papeletas totales table_answer: Respuesta table_votes: Votos + results_by_booth: + booth: Urna + results: Resultados + see_results: Ver resultados booths: index: title: "Lista de urnas" From 0499fb6fefd197b745a87d5fa371cdcd89a25187 Mon Sep 17 00:00:00 2001 From: rgarcia Date: Wed, 18 Oct 2017 20:48:44 +0200 Subject: [PATCH 15/25] highlights result's tab --- app/views/admin/poll/booth_assignments/show.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/admin/poll/booth_assignments/show.html.erb b/app/views/admin/poll/booth_assignments/show.html.erb index c69631dee..71938cce5 100644 --- a/app/views/admin/poll/booth_assignments/show.html.erb +++ b/app/views/admin/poll/booth_assignments/show.html.erb @@ -20,7 +20,7 @@
  • <%= link_to t("admin.poll_booth_assignments.show.recounts"), "#tab-recounts" %>
  • -
  • +
  • <%= link_to t("admin.poll_booth_assignments.show.results"), "#tab-results" %>
  • From 6a697bd6d0e07310d90dc3a6206cb2ae849a7acb Mon Sep 17 00:00:00 2001 From: rgarcia Date: Wed, 18 Oct 2017 20:50:46 +0200 Subject: [PATCH 16/25] adds specs --- .../admin/poll/booth_assigments_spec.rb | 86 +++++++++++++++++++ spec/features/admin/poll/polls_spec.rb | 37 ++++++++ 2 files changed, 123 insertions(+) diff --git a/spec/features/admin/poll/booth_assigments_spec.rb b/spec/features/admin/poll/booth_assigments_spec.rb index 77881efaa..b527170d2 100644 --- a/spec/features/admin/poll/booth_assigments_spec.rb +++ b/spec/features/admin/poll/booth_assigments_spec.rb @@ -126,5 +126,91 @@ feature 'Admin booths assignments' do end end + scenario 'Results' do + poll = create(:poll) + booth_assignment = create(:poll_booth_assignment, poll: poll) + + question_1 = create(:poll_question, poll: poll) + create(:poll_question_answer, title: 'Yes', question: question_1) + create(:poll_question_answer, title: 'No', question: question_1) + + question_2 = create(:poll_question, poll: poll) + create(:poll_question_answer, title: 'Today', question: question_2) + create(:poll_question_answer, title: 'Tomorrow', question: question_2) + + create(:poll_partial_result, + booth_assignment: booth_assignment, + question: question_1, + answer: 'Yes', + amount: 11) + + create(:poll_partial_result, + booth_assignment: booth_assignment, + question: question_1, + answer: 'No', + amount: 4) + + create(:poll_partial_result, + booth_assignment: booth_assignment, + question: question_2, + answer: 'Today', + amount: 5) + + create(:poll_partial_result, + booth_assignment: booth_assignment, + question: question_2, + answer: 'Tomorrow', + amount: 6) + + create(:poll_recount, + booth_assignment: booth_assignment, + white_amount: 21, + null_amount: 44, + total_amount: 66) + + visit admin_poll_booth_assignment_path(poll, booth_assignment) + + click_link 'Results' + + expect(page).to have_content(question_1.title) + + within("#question_#{question_1.id}_0_result") do + expect(page).to have_content("Yes") + expect(page).to have_content(11) + end + + within("#question_#{question_1.id}_1_result") do + expect(page).to have_content("No") + expect(page).to have_content(4) + end + + expect(page).to have_content(question_2.title) + + within("#question_#{question_2.id}_0_result") do + expect(page).to have_content("Today") + expect(page).to have_content(5) + end + + within("#question_#{question_2.id}_1_result") do + expect(page).to have_content("Tomorrow") + expect(page).to have_content(6) + end + + within('#white_results') { expect(page).to have_content('21') } + within('#null_results') { expect(page).to have_content('44') } + within('#total_results') { expect(page).to have_content('66') } + end + + scenario "No results" do + poll = create(:poll) + booth_assignment = create(:poll_booth_assignment, poll: poll) + + visit admin_poll_booth_assignment_path(poll, booth_assignment) + + click_link "Results" + + expect(page).to have_content "There are no results" + end + end end diff --git a/spec/features/admin/poll/polls_spec.rb b/spec/features/admin/poll/polls_spec.rb index 9c2d3fcf1..2a2d26ea5 100644 --- a/spec/features/admin/poll/polls_spec.rb +++ b/spec/features/admin/poll/polls_spec.rb @@ -311,6 +311,43 @@ feature 'Admin polls' do within('#null_results') { expect(page).to have_content('44') } within('#total_results') { expect(page).to have_content('66') } end + + scenario "Link to results by booth" do + poll = create(:poll) + booth_assignment1 = create(:poll_booth_assignment, poll: poll) + booth_assignment2 = create(:poll_booth_assignment, poll: poll) + + question = create(:poll_question, poll: poll) + create(:poll_question_answer, title: 'Yes', question: question) + create(:poll_question_answer, title: 'No', question: question) + + create(:poll_partial_result, + booth_assignment: booth_assignment1, + question: question, + answer: 'Yes', + amount: 5) + + create(:poll_partial_result, + booth_assignment: booth_assignment2, + question: question, + answer: 'Yes', + amount: 6) + + visit admin_poll_path(poll) + + click_link "Results" + + expect(page).to have_link("See results", count: 2) + + within("#booth_assignment_#{booth_assignment1.id}_result") do + click_link "See results" + end + + expect(page).to have_content booth_assignment1.booth.name + expect(page).to have_content "Results" + expect(page).to have_content "Yes" + expect(page).to have_content "5" + end end end From fcbcca3b6002b02212861d60c210f04b00353682 Mon Sep 17 00:00:00 2001 From: rgarcia Date: Wed, 18 Oct 2017 22:21:47 +0200 Subject: [PATCH 17/25] sorts booths by name --- app/views/admin/poll/results/_results_by_booth.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/admin/poll/results/_results_by_booth.html.erb b/app/views/admin/poll/results/_results_by_booth.html.erb index 8778a7434..4e2a8bcae 100644 --- a/app/views/admin/poll/results/_results_by_booth.html.erb +++ b/app/views/admin/poll/results/_results_by_booth.html.erb @@ -6,7 +6,7 @@
    - <% @poll.booth_assignments.each do |booth_assignment| %> + <% @poll.booth_assignments.sort_by {|ba| ba.booth.name }.each do |booth_assignment| %>
    UrnaResultados<%= t("admin.results.results_by_booth.booth") %><%= t("admin.results.results_by_booth.results") %>
    <%= booth_assignment.booth.name %> - <%= link_to "See results", - admin_poll_booth_assignment_path(@poll, booth_assignment, anchor: "tab-results") %> + <%= link_to t("admin.results.results_by_booth.see_results"), + admin_poll_booth_assignment_path(@poll, booth_assignment, + anchor: "tab-results") %>
    <%= booth_assignment.booth.name %> From 5d3654f92f9fe872e29ab017e523def0978125e0 Mon Sep 17 00:00:00 2001 From: rgarcia Date: Wed, 18 Oct 2017 22:40:41 +0200 Subject: [PATCH 18/25] refactors recounts into partial --- app/views/admin/poll/results/_recount.html.erb | 14 ++++++++++++++ app/views/admin/poll/results/_result.html.erb | 16 ---------------- app/views/admin/poll/results/index.html.erb | 1 + 3 files changed, 15 insertions(+), 16 deletions(-) create mode 100644 app/views/admin/poll/results/_recount.html.erb diff --git a/app/views/admin/poll/results/_recount.html.erb b/app/views/admin/poll/results/_recount.html.erb new file mode 100644 index 000000000..f4ab43954 --- /dev/null +++ b/app/views/admin/poll/results/_recount.html.erb @@ -0,0 +1,14 @@ + + + + + + + + + + + + + +
    <%= t("admin.results.result.table_whites") %><%= t("admin.results.result.table_nulls") %><%= t("admin.results.result.table_total") %>
    <%= resource.recounts.sum(:white_amount) %><%= resource.recounts.sum(:null_amount) %><%= resource.recounts.sum(:total_amount) %>
    \ No newline at end of file diff --git a/app/views/admin/poll/results/_result.html.erb b/app/views/admin/poll/results/_result.html.erb index 64da2c9b2..e2fe5f037 100644 --- a/app/views/admin/poll/results/_result.html.erb +++ b/app/views/admin/poll/results/_result.html.erb @@ -1,19 +1,3 @@ - - - - - - - - - - - - - -
    <%= t("admin.results.result.table_whites") %><%= t("admin.results.result.table_nulls") %><%= t("admin.results.result.table_total") %>
    <%= @poll.recounts.sum(:white_amount) %><%= @poll.recounts.sum(:null_amount) %><%= @poll.recounts.sum(:total_amount) %>
    - - <% by_question = @partial_results.group_by(&:question_id) %> <% @poll.questions.each do |question| %>

    <%= question.title %>

    diff --git a/app/views/admin/poll/results/index.html.erb b/app/views/admin/poll/results/index.html.erb index f4823ccd4..7f21e5452 100644 --- a/app/views/admin/poll/results/index.html.erb +++ b/app/views/admin/poll/results/index.html.erb @@ -9,6 +9,7 @@ <%= t("admin.results.index.no_results") %> <% else %> + <%= render "recount", resource: @poll %> <%= render "result" %> <%= render "results_by_booth" %> <% end %> From 39ebc5173a3d34f11cc952ace04fd5fe94edcbf1 Mon Sep 17 00:00:00 2001 From: rgarcia Date: Wed, 18 Oct 2017 22:40:53 +0200 Subject: [PATCH 19/25] displays recounts for a single booth --- app/controllers/admin/poll/booth_assignments_controller.rb | 1 + app/views/admin/poll/booth_assignments/_results.html.erb | 1 + 2 files changed, 2 insertions(+) diff --git a/app/controllers/admin/poll/booth_assignments_controller.rb b/app/controllers/admin/poll/booth_assignments_controller.rb index c9f95de30..7998f29a2 100644 --- a/app/controllers/admin/poll/booth_assignments_controller.rb +++ b/app/controllers/admin/poll/booth_assignments_controller.rb @@ -19,6 +19,7 @@ class Admin::Poll::BoothAssignmentsController < Admin::Poll::BaseController officer_assignments: [officer: [:user]]).find(params[:id]) @voters_by_date = @booth_assignment.voters.group_by {|v| v.created_at.to_date} @partial_results = @booth_assignment.partial_results + @recounts = @booth_assignment.recounts end def create diff --git a/app/views/admin/poll/booth_assignments/_results.html.erb b/app/views/admin/poll/booth_assignments/_results.html.erb index 224da76ab..1b3f1ec08 100644 --- a/app/views/admin/poll/booth_assignments/_results.html.erb +++ b/app/views/admin/poll/booth_assignments/_results.html.erb @@ -6,6 +6,7 @@ <%= t("admin.results.index.no_results") %> <% else %> + <%= render "admin/poll/results/recount", resource: @booth_assignment %> <%= render "admin/poll/results/result" %> <% end %> \ No newline at end of file From 98f5d70e6d7e84bc534044dc7e11dd96a2c7e0a2 Mon Sep 17 00:00:00 2001 From: rgarcia Date: Wed, 18 Oct 2017 22:41:31 +0200 Subject: [PATCH 20/25] makes specs more robust --- spec/features/admin/poll/booth_assigments_spec.rb | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/spec/features/admin/poll/booth_assigments_spec.rb b/spec/features/admin/poll/booth_assigments_spec.rb index b527170d2..5813e2dac 100644 --- a/spec/features/admin/poll/booth_assigments_spec.rb +++ b/spec/features/admin/poll/booth_assigments_spec.rb @@ -126,9 +126,10 @@ feature 'Admin booths assignments' do end end - scenario 'Results' do + scenario 'Results for a booth assignment' do poll = create(:poll) booth_assignment = create(:poll_booth_assignment, poll: poll) + other_booth_assignment = create(:poll_booth_assignment, poll: poll) question_1 = create(:poll_question, poll: poll) create(:poll_question_answer, title: 'Yes', question: question_1) @@ -162,12 +163,24 @@ feature 'Admin booths assignments' do answer: 'Tomorrow', amount: 6) + create(:poll_partial_result, + booth_assignment: other_booth_assignment, + question: question_1, + answer: 'Yes', + amount: 9999) + create(:poll_recount, booth_assignment: booth_assignment, white_amount: 21, null_amount: 44, total_amount: 66) + create(:poll_recount, + booth_assignment: other_booth_assignment, + white_amount: 999, + null_amount: 999, + total_amount: 999) + visit admin_poll_booth_assignment_path(poll, booth_assignment) click_link 'Results' From b6e080abca6525d4e1d0fa583917607812f92962 Mon Sep 17 00:00:00 2001 From: rgarcia Date: Thu, 19 Oct 2017 10:25:14 +0200 Subject: [PATCH 21/25] fixes alignment --- app/views/admin/poll/booth_assignments/_results.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/admin/poll/booth_assignments/_results.html.erb b/app/views/admin/poll/booth_assignments/_results.html.erb index 1b3f1ec08..fdbc4da3f 100644 --- a/app/views/admin/poll/booth_assignments/_results.html.erb +++ b/app/views/admin/poll/booth_assignments/_results.html.erb @@ -6,7 +6,7 @@ <%= t("admin.results.index.no_results") %> <% else %> - <%= render "admin/poll/results/recount", resource: @booth_assignment %> + <%= render "admin/poll/results/recount", resource: @booth_assignment %> <%= render "admin/poll/results/result" %> <% end %> \ No newline at end of file From 1ae91017b445bc78e53ef2e8acac2b934f39cf2c Mon Sep 17 00:00:00 2001 From: rgarcia Date: Thu, 19 Oct 2017 10:28:35 +0200 Subject: [PATCH 22/25] adds heading to results by booth table --- app/views/admin/poll/results/_results_by_booth.html.erb | 3 ++- config/locales/en/admin.yml | 1 + config/locales/es/admin.yml | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/views/admin/poll/results/_results_by_booth.html.erb b/app/views/admin/poll/results/_results_by_booth.html.erb index 4e2a8bcae..58d7ea83c 100644 --- a/app/views/admin/poll/results/_results_by_booth.html.erb +++ b/app/views/admin/poll/results/_results_by_booth.html.erb @@ -1,4 +1,5 @@ - +

    <%= t("admin.results.results_by_booth.title") %>

    +
    diff --git a/config/locales/en/admin.yml b/config/locales/en/admin.yml index 2b6f2988e..38abe6f56 100644 --- a/config/locales/en/admin.yml +++ b/config/locales/en/admin.yml @@ -658,6 +658,7 @@ en: booth: Booth results: Results see_results: See results + title: "Results by booth" booths: index: title: "List of booths" diff --git a/config/locales/es/admin.yml b/config/locales/es/admin.yml index 26e2d18dc..3336cdc5b 100644 --- a/config/locales/es/admin.yml +++ b/config/locales/es/admin.yml @@ -660,6 +660,7 @@ es: booth: Urna results: Resultados see_results: Ver resultados + title: "Resultados por urna" booths: index: title: "Lista de urnas" From 7ddc225d8b60b50d8c7b4d584b2ee6e8eec52c7a Mon Sep 17 00:00:00 2001 From: rgarcia Date: Thu, 19 Oct 2017 10:31:24 +0200 Subject: [PATCH 23/25] fixes alignment for link params --- app/views/admin/poll/results/_results_by_booth.html.erb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/views/admin/poll/results/_results_by_booth.html.erb b/app/views/admin/poll/results/_results_by_booth.html.erb index 58d7ea83c..9266a58fb 100644 --- a/app/views/admin/poll/results/_results_by_booth.html.erb +++ b/app/views/admin/poll/results/_results_by_booth.html.erb @@ -11,9 +11,8 @@ <% end %> From f20db4e3e4710b63a7a2647471f4203d0cc5c7db Mon Sep 17 00:00:00 2001 From: Bertocq Date: Thu, 19 Oct 2017 13:32:48 +0200 Subject: [PATCH 24/25] Fix user helper expectation --- spec/helpers/users_helper_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/helpers/users_helper_spec.rb b/spec/helpers/users_helper_spec.rb index 55ea8445b..fe2cdd786 100644 --- a/spec/helpers/users_helper_spec.rb +++ b/spec/helpers/users_helper_spec.rb @@ -35,7 +35,7 @@ describe UsersHelper do investment.hide - expect(comment_commentable_title(comment)).to eq '' + comment.commentable.title + ' (This investment has been deleted)' + expect(comment_commentable_title(comment)).to eq '' + comment.commentable.title + ' (This investment project has been deleted)' end end From 3daf9578134d1f512ffcc990b9cb48afee002f65 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Thu, 19 Oct 2017 13:35:04 +0200 Subject: [PATCH 25/25] Fix table tag indentation --- app/views/admin/poll/results/_results_by_booth.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/admin/poll/results/_results_by_booth.html.erb b/app/views/admin/poll/results/_results_by_booth.html.erb index 9266a58fb..f270adaab 100644 --- a/app/views/admin/poll/results/_results_by_booth.html.erb +++ b/app/views/admin/poll/results/_results_by_booth.html.erb @@ -1,5 +1,5 @@

    <%= t("admin.results.results_by_booth.title") %>

    -
    <%= t("admin.results.results_by_booth.booth") %>
    <%= booth_assignment.booth.name %> - <%= link_to t("admin.results.results_by_booth.see_results"), - admin_poll_booth_assignment_path(@poll, booth_assignment, - anchor: "tab-results") %> + <%= link_to t("admin.results.results_by_booth.see_results"), + admin_poll_booth_assignment_path(@poll, booth_assignment, anchor: "tab-results") %>
    +
    @@ -17,4 +17,4 @@ <% end %> -
    <%= t("admin.results.results_by_booth.booth") %>
    \ No newline at end of file +