From 0b708397df195c1c92d613448c2b61c28c9e4146 Mon Sep 17 00:00:00 2001 From: Angel Perez Date: Wed, 13 Sep 2017 12:22:57 -0400 Subject: [PATCH 001/161] Add base controller for Admin:Poll controller Fixes #1848 On branch aperez-fix-for-issue-1848 Changes to be committed: new file: app/controllers/admin/poll/base_controller.rb modified: app/controllers/admin/poll/booth_assignments_controller.rb modified: app/controllers/admin/poll/booths_controller.rb modified: app/controllers/admin/poll/officer_assignments_controller.rb modified: app/controllers/admin/poll/officers_controller.rb modified: app/controllers/admin/poll/polls_controller.rb modified: app/controllers/admin/poll/questions_controller.rb modified: app/controllers/admin/poll/recounts_controller.rb modified: app/controllers/admin/poll/results_controller.rb modified: app/controllers/admin/poll/shifts_controller.rb --- app/controllers/admin/poll/base_controller.rb | 10 ++++++++++ .../admin/poll/booth_assignments_controller.rb | 2 +- app/controllers/admin/poll/booths_controller.rb | 4 ++-- .../admin/poll/officer_assignments_controller.rb | 2 +- app/controllers/admin/poll/officers_controller.rb | 4 ++-- app/controllers/admin/poll/polls_controller.rb | 2 +- app/controllers/admin/poll/questions_controller.rb | 2 +- app/controllers/admin/poll/recounts_controller.rb | 2 +- app/controllers/admin/poll/results_controller.rb | 4 ++-- app/controllers/admin/poll/shifts_controller.rb | 6 +++--- 10 files changed, 24 insertions(+), 14 deletions(-) create mode 100644 app/controllers/admin/poll/base_controller.rb diff --git a/app/controllers/admin/poll/base_controller.rb b/app/controllers/admin/poll/base_controller.rb new file mode 100644 index 000000000..c58e4f23c --- /dev/null +++ b/app/controllers/admin/poll/base_controller.rb @@ -0,0 +1,10 @@ +class Admin::Poll::BaseController < Admin::BaseController + helper_method :namespace + + private + + def namespace + "admin" + end + +end diff --git a/app/controllers/admin/poll/booth_assignments_controller.rb b/app/controllers/admin/poll/booth_assignments_controller.rb index 358f26a65..72b8347cc 100644 --- a/app/controllers/admin/poll/booth_assignments_controller.rb +++ b/app/controllers/admin/poll/booth_assignments_controller.rb @@ -1,4 +1,4 @@ -class Admin::Poll::BoothAssignmentsController < Admin::BaseController +class Admin::Poll::BoothAssignmentsController < Admin::Poll::BaseController before_action :load_poll, except: [:create, :destroy] diff --git a/app/controllers/admin/poll/booths_controller.rb b/app/controllers/admin/poll/booths_controller.rb index 4b322f0b2..7a3a1370d 100644 --- a/app/controllers/admin/poll/booths_controller.rb +++ b/app/controllers/admin/poll/booths_controller.rb @@ -1,4 +1,4 @@ -class Admin::Poll::BoothsController < Admin::BaseController +class Admin::Poll::BoothsController < Admin::Poll::BaseController load_and_authorize_resource class: 'Poll::Booth' def index @@ -41,4 +41,4 @@ class Admin::Poll::BoothsController < Admin::BaseController params.require(:poll_booth).permit(:name, :location) end -end \ No newline at end of file +end diff --git a/app/controllers/admin/poll/officer_assignments_controller.rb b/app/controllers/admin/poll/officer_assignments_controller.rb index 45c9a225a..5039df701 100644 --- a/app/controllers/admin/poll/officer_assignments_controller.rb +++ b/app/controllers/admin/poll/officer_assignments_controller.rb @@ -1,4 +1,4 @@ -class Admin::Poll::OfficerAssignmentsController < Admin::BaseController +class Admin::Poll::OfficerAssignmentsController < Admin::Poll::BaseController before_action :load_poll before_action :redirect_if_blank_required_params, only: [:by_officer] diff --git a/app/controllers/admin/poll/officers_controller.rb b/app/controllers/admin/poll/officers_controller.rb index 2641a12b5..1d5c19634 100644 --- a/app/controllers/admin/poll/officers_controller.rb +++ b/app/controllers/admin/poll/officers_controller.rb @@ -1,4 +1,4 @@ -class Admin::Poll::OfficersController < Admin::BaseController +class Admin::Poll::OfficersController < Admin::Poll::BaseController load_and_authorize_resource :officer, class: "Poll::Officer", except: [:edit, :show] def index @@ -36,4 +36,4 @@ class Admin::Poll::OfficersController < Admin::BaseController def edit end -end \ No newline at end of file +end diff --git a/app/controllers/admin/poll/polls_controller.rb b/app/controllers/admin/poll/polls_controller.rb index cad91f218..c95c8ed1f 100644 --- a/app/controllers/admin/poll/polls_controller.rb +++ b/app/controllers/admin/poll/polls_controller.rb @@ -1,4 +1,4 @@ -class Admin::Poll::PollsController < Admin::BaseController +class Admin::Poll::PollsController < Admin::Poll::BaseController load_and_authorize_resource before_action :load_search, only: [:search_booths, :search_questions, :search_officers] diff --git a/app/controllers/admin/poll/questions_controller.rb b/app/controllers/admin/poll/questions_controller.rb index 3bbe1c395..8f6c18841 100644 --- a/app/controllers/admin/poll/questions_controller.rb +++ b/app/controllers/admin/poll/questions_controller.rb @@ -1,4 +1,4 @@ -class Admin::Poll::QuestionsController < Admin::BaseController +class Admin::Poll::QuestionsController < Admin::Poll::BaseController include CommentableActions load_and_authorize_resource :poll diff --git a/app/controllers/admin/poll/recounts_controller.rb b/app/controllers/admin/poll/recounts_controller.rb index 57289a207..6453b5fa3 100644 --- a/app/controllers/admin/poll/recounts_controller.rb +++ b/app/controllers/admin/poll/recounts_controller.rb @@ -1,4 +1,4 @@ -class Admin::Poll::RecountsController < Admin::BaseController +class Admin::Poll::RecountsController < Admin::Poll::BaseController before_action :load_poll def index diff --git a/app/controllers/admin/poll/results_controller.rb b/app/controllers/admin/poll/results_controller.rb index 2c5bbba27..8d1d22d91 100644 --- a/app/controllers/admin/poll/results_controller.rb +++ b/app/controllers/admin/poll/results_controller.rb @@ -1,4 +1,4 @@ -class Admin::Poll::ResultsController < Admin::BaseController +class Admin::Poll::ResultsController < Admin::Poll::BaseController before_action :load_poll def index @@ -10,4 +10,4 @@ class Admin::Poll::ResultsController < Admin::BaseController def load_poll @poll = ::Poll.includes(:questions).find(params[:poll_id]) end -end \ No newline at end of file +end diff --git a/app/controllers/admin/poll/shifts_controller.rb b/app/controllers/admin/poll/shifts_controller.rb index 168284474..48f540c07 100644 --- a/app/controllers/admin/poll/shifts_controller.rb +++ b/app/controllers/admin/poll/shifts_controller.rb @@ -1,5 +1,5 @@ -class Admin::Poll::ShiftsController < Admin::BaseController - +class Admin::Poll::ShiftsController < Admin::Poll::BaseController + before_action :load_booth before_action :load_polls before_action :load_officer @@ -57,4 +57,4 @@ class Admin::Poll::ShiftsController < Admin::BaseController params.require(:shift).permit(:booth_id, :officer_id, :date) end -end \ No newline at end of file +end From 12d34a3ea1366fec274651a5a845c17bfb13e7ac Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Mon, 18 Sep 2017 19:07:18 +0200 Subject: [PATCH 002/161] Switch flag/unflag buttons on use via ajax --- app/assets/javascripts/application.js | 1 + app/assets/javascripts/flagable.js.coffee | 4 ++++ app/views/proposals/_refresh_flag_actions.js.erb | 3 ++- app/views/proposals/show.html.erb | 4 +++- 4 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 app/assets/javascripts/flagable.js.coffee diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 2ff87100a..32c0330f5 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -60,6 +60,7 @@ //= require legislation_annotatable //= require watch_form_changes //= require followable +//= require flagable //= require documentable //= require tree_navigator //= require custom diff --git a/app/assets/javascripts/flagable.js.coffee b/app/assets/javascripts/flagable.js.coffee new file mode 100644 index 000000000..417acf1a7 --- /dev/null +++ b/app/assets/javascripts/flagable.js.coffee @@ -0,0 +1,4 @@ +App.Flagable = + + update: (proposal_id, button) -> + $("#" + proposal_id + " .js-flag-actions-container").html(button).foundation() diff --git a/app/views/proposals/_refresh_flag_actions.js.erb b/app/views/proposals/_refresh_flag_actions.js.erb index 0e20636ae..8b563743b 100644 --- a/app/views/proposals/_refresh_flag_actions.js.erb +++ b/app/views/proposals/_refresh_flag_actions.js.erb @@ -1 +1,2 @@ -$("#<%= dom_id(@proposal) %> .js-flag-actions").html('<%= j render("proposals/flag_actions", proposal: @proposal) %>'); +App.Flagable.update("<%= dom_id(@proposal) %>", + "<%= j render("proposals/flag_actions", proposal: @proposal) %>") diff --git a/app/views/proposals/show.html.erb b/app/views/proposals/show.html.erb index 1dc918e8e..29e26efff 100644 --- a/app/views/proposals/show.html.erb +++ b/app/views/proposals/show.html.erb @@ -59,7 +59,9 @@ <% if current_user %>  •  - <%= render 'proposals/flag_actions', proposal: @proposal %> + + <%= render 'proposals/flag_actions', proposal: @proposal %> + <% end %> From f27fcc7f9937cda8b75af27d6a6dd0c19e7c1b1a Mon Sep 17 00:00:00 2001 From: Bertocq Date: Mon, 18 Sep 2017 20:49:34 +0200 Subject: [PATCH 003/161] Replace FinalResult with TotalResult at admin BoothAssignment show --- app/helpers/poll_final_recounts_helper.rb | 7 ------- app/views/admin/poll/booth_assignments/show.html.erb | 8 ++++---- config/locales/en/admin.yml | 2 +- config/locales/es/admin.yml | 2 +- config/locales/fr/admin.yml | 2 +- config/locales/nl/admin.yml | 2 +- spec/features/admin/poll/booth_assigments_spec.rb | 8 ++++---- 7 files changed, 12 insertions(+), 19 deletions(-) delete mode 100644 app/helpers/poll_final_recounts_helper.rb diff --git a/app/helpers/poll_final_recounts_helper.rb b/app/helpers/poll_final_recounts_helper.rb deleted file mode 100644 index e196cb65b..000000000 --- a/app/helpers/poll_final_recounts_helper.rb +++ /dev/null @@ -1,7 +0,0 @@ -module PollFinalRecountsHelper - - def final_recount_for_date(final_recounts, date) - final_recounts.select {|f| f.date == date}.first - end - -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 5b3ca41ab..b6917bca6 100644 --- a/app/views/admin/poll/booth_assignments/show.html.erb +++ b/app/views/admin/poll/booth_assignments/show.html.erb @@ -49,18 +49,18 @@ <%= t("admin.poll_booth_assignments.show.date") %> - <%= t("admin.poll_booth_assignments.show.count_final") %> + <%= t("admin.poll_booth_assignments.show.total_recount") %> <%= t("admin.poll_booth_assignments.show.count_by_system") %> <% (@poll.starts_at.to_date..@poll.ends_at.to_date).each do |voting_date| %> - <% final_recount = final_recount_for_date(@booth_assignment.final_recounts, voting_date) %> + <% total_recount = @booth_assignment.total_results.where(date: voting_date).first %> <% system_count = @voters_by_date[voting_date].present? ? @voters_by_date[voting_date].size : 0 %> <%= l voting_date %> - <% if final_recount.present? %> - <%= final_recount.count %> + <% if total_recount.present? %> + <%= total_recount.amount %> <% else %> - <% end %> diff --git a/config/locales/en/admin.yml b/config/locales/en/admin.yml index 91b493ffa..6e01fdccf 100644 --- a/config/locales/en/admin.yml +++ b/config/locales/en/admin.yml @@ -531,7 +531,7 @@ en: recounts: "Recounts" recounts_list: "Recount list for this booth" date: "Date" - count_final: "Final recount (by officer)" + total_recount: "Total recount (by officer)" count_by_system: "Votes (automatic)" index: booths_title: "List of booths" diff --git a/config/locales/es/admin.yml b/config/locales/es/admin.yml index 2db094999..6bf881d30 100644 --- a/config/locales/es/admin.yml +++ b/config/locales/es/admin.yml @@ -531,7 +531,7 @@ es: recounts: "Recuentos" recounts_list: "Lista de recuentos de esta urna" date: "Fecha" - count_final: "Recuento final (presidente de mesa)" + total_recount: "Recuento total (presidente de mesa)" count_by_system: "Votos (automático)" index: booths_title: "Listado de urnas asignadas" diff --git a/config/locales/fr/admin.yml b/config/locales/fr/admin.yml index 0044a276f..a34862475 100644 --- a/config/locales/fr/admin.yml +++ b/config/locales/fr/admin.yml @@ -319,7 +319,7 @@ fr: no_recounts: "Il n'y a pas encore de dépouillements journaliers pour ce bureau de vote." date: "Date" count_by_officer: "Dépouillement journalier (par président)" - count_final: "Dépouillement final (par président)" + total_count: "Dépouillement final (par président)" count_by_system: "Votes (automatique)" index: booths_title: "Liste des bureaux de vote" diff --git a/config/locales/nl/admin.yml b/config/locales/nl/admin.yml index a359aebbe..2949f70f4 100644 --- a/config/locales/nl/admin.yml +++ b/config/locales/nl/admin.yml @@ -319,7 +319,7 @@ nl: no_recounts: "There are not daily recounts of this booth yet" date: "Date" count_by_officer: "Daily recount (by officer)" - count_final: "Final recount (by officer)" + total_count: "Final recount (by officer)" count_by_system: "Votes (automatic)" index: booths_title: "List of booths" diff --git a/spec/features/admin/poll/booth_assigments_spec.rb b/spec/features/admin/poll/booth_assigments_spec.rb index bcc27310f..09a21dd72 100644 --- a/spec/features/admin/poll/booth_assigments_spec.rb +++ b/spec/features/admin/poll/booth_assigments_spec.rb @@ -97,11 +97,11 @@ feature 'Admin booths assignments' do officer_assignment_2 = create(:poll_officer_assignment, booth_assignment: booth_assignment, date: poll.ends_at) final_officer_assignment = create(:poll_officer_assignment, :final, booth_assignment: booth_assignment, date: poll.ends_at) - final_recount = create(:poll_final_recount, + total_recount = create(:poll_total_result, booth_assignment: booth_assignment, officer_assignment: final_officer_assignment, date: final_officer_assignment.date, - count: 5678) + amount: 5678) booth_assignment_2 = create(:poll_booth_assignment, poll: poll) @@ -112,8 +112,8 @@ feature 'Admin booths assignments' do click_link 'Recounts' within('#recounts_list') do - within("#recounting_#{final_recount.date.strftime('%Y%m%d')}") do - expect(page).to have_content final_recount.count + within("#recounting_#{total_recount.date.strftime('%Y%m%d')}") do + expect(page).to have_content total_recount.amount end end end From 851d39739579eb0dab11d5f90b69411e15759e27 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Tue, 19 Sep 2017 00:54:46 +0200 Subject: [PATCH 004/161] Replace FinalResult with TotalResult at admin Poll Recounts page --- app/helpers/poll_recounts_helper.rb | 4 ++-- app/views/admin/poll/recounts/index.html.erb | 10 +++++----- config/locales/en/admin.yml | 2 +- config/locales/es/admin.yml | 2 +- config/locales/fr/admin.yml | 2 +- config/locales/nl/admin.yml | 2 +- spec/features/admin/poll/polls_spec.rb | 8 ++++---- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/app/helpers/poll_recounts_helper.rb b/app/helpers/poll_recounts_helper.rb index 95ea813e3..716b71d85 100644 --- a/app/helpers/poll_recounts_helper.rb +++ b/app/helpers/poll_recounts_helper.rb @@ -1,7 +1,7 @@ module PollRecountsHelper - def booth_assignment_sum_final_recounts(ba) - ba.final_recounts.any? ? ba.final_recounts.to_a.sum(&:count) : nil + def total_recounts_by_booth(booth_assignment) + booth_assignment.total_results.any? ? booth_assignment.total_results.to_a.sum(&:amount) : nil end end diff --git a/app/views/admin/poll/recounts/index.html.erb b/app/views/admin/poll/recounts/index.html.erb index 159b4b120..ff4e7bceb 100644 --- a/app/views/admin/poll/recounts/index.html.erb +++ b/app/views/admin/poll/recounts/index.html.erb @@ -12,12 +12,12 @@ - + <% @booth_assignments.each do |booth_assignment| %> - <% final_recount = booth_assignment_sum_final_recounts(booth_assignment) %> + <% total_recounts = total_recounts_by_booth(booth_assignment) %> <% system_count = booth_assignment.voters.size %> -
<%= t("admin.recounts.index.table_booth_name") %><%= t("admin.recounts.index.table_final_recount") %><%= t("admin.recounts.index.table_total_recount") %> <%= t("admin.recounts.index.table_system_count") %>
@@ -25,9 +25,9 @@ <%= link_to booth_assignment.booth.name, admin_poll_booth_assignment_path(@poll, booth_assignment, anchor: 'tab-recounts') %> - <% if final_recount.present? %> - <%= final_recount %> + + <% if total_recounts.present? %> + <%= total_recounts %> <% else %> - <% end %> diff --git a/config/locales/en/admin.yml b/config/locales/en/admin.yml index 6e01fdccf..63fb7c70c 100644 --- a/config/locales/en/admin.yml +++ b/config/locales/en/admin.yml @@ -604,7 +604,7 @@ en: title: "Recounts" no_recounts: "There is nothing to be recounted" table_booth_name: "Booth" - table_final_recount: "Final recount (by officer)" + table_total_recount: "Total recount (by officer)" table_system_count: "Votes (automatic)" results: index: diff --git a/config/locales/es/admin.yml b/config/locales/es/admin.yml index 6bf881d30..0e1f0db65 100644 --- a/config/locales/es/admin.yml +++ b/config/locales/es/admin.yml @@ -604,7 +604,7 @@ es: title: "Recuentos" no_recounts: "No hay nada de lo que hacer recuento" table_booth_name: "Urna" - table_final_recount: "Recuento final (presidente de mesa)" + table_total_recount: "Recuento total (presidente de mesa)" table_system_count: "Votos (automático)" results: index: diff --git a/config/locales/fr/admin.yml b/config/locales/fr/admin.yml index a34862475..966563b7c 100644 --- a/config/locales/fr/admin.yml +++ b/config/locales/fr/admin.yml @@ -391,7 +391,7 @@ fr: no_recounts: "Il n'y a rien à dépouiller" table_booth_name: "Bureau de vote" table_recounts: "Accumulation des dépouillements journaliers (par président)" - table_final_recount: "Dépouillement final (par président)" + table_total_recount: "Dépouillement final (par président)" table_system_count: "Votes (automatique)" results: index: diff --git a/config/locales/nl/admin.yml b/config/locales/nl/admin.yml index 2949f70f4..c7d77cda9 100644 --- a/config/locales/nl/admin.yml +++ b/config/locales/nl/admin.yml @@ -391,7 +391,7 @@ nl: no_recounts: "There is nothing to be recounted" table_booth_name: "Booth" table_recounts: "Accumulated daily recounts (by officer)" - table_final_recount: "Final recount (by officer)" + table_total_recount: "Final recount (by officer)" table_system_count: "Votes (automatic)" results: index: diff --git a/spec/features/admin/poll/polls_spec.rb b/spec/features/admin/poll/polls_spec.rb index ee90d2ada..e5997fa33 100644 --- a/spec/features/admin/poll/polls_spec.rb +++ b/spec/features/admin/poll/polls_spec.rb @@ -249,18 +249,18 @@ feature 'Admin polls' do booth_assignment_final_recounted = create(:poll_booth_assignment, poll: poll) 3.times do |i| - create(:poll_final_recount, + create(:poll_total_result, booth_assignment: booth_assignment, date: poll.starts_at + i.days, - count: 21) + amount: 21) end 2.times { create(:poll_voter, booth_assignment: booth_assignment_final_recounted) } - create(:poll_final_recount, + create(:poll_total_result, booth_assignment: booth_assignment_final_recounted, date: poll.ends_at, - count: 55555) + amount: 55555) visit admin_poll_path(poll) From 1c1bb7bf38367e087886f974d486a4d5b9fbb6a3 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Tue, 19 Sep 2017 01:09:05 +0200 Subject: [PATCH 005/161] Remove no longer used functions --- app/helpers/officing_helper.rb | 12 ------------ app/helpers/polls_helper.rb | 7 +------ 2 files changed, 1 insertion(+), 18 deletions(-) diff --git a/app/helpers/officing_helper.rb b/app/helpers/officing_helper.rb index 4e824b3f2..3d53acf6d 100644 --- a/app/helpers/officing_helper.rb +++ b/app/helpers/officing_helper.rb @@ -1,13 +1,5 @@ module OfficingHelper - def officer_assignments_select_options(officer_assignments) - options = [] - officer_assignments.each do |oa| - options << ["#{oa.booth_assignment.booth.name}: #{l(oa.date.to_date, format: :long)}", oa.id] - end - options_for_select(options) - end - def booths_for_officer_select_options(officer_assignments) options = [] officer_assignments.each do |oa| @@ -17,10 +9,6 @@ module OfficingHelper options_for_select(options, params[:oa]) 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 - def answer_result_value(question_id, answer_index) return nil if params.blank? return nil if params[:questions].blank? diff --git a/app/helpers/polls_helper.rb b/app/helpers/polls_helper.rb index 169599a7c..27d33ea04 100644 --- a/app/helpers/polls_helper.rb +++ b/app/helpers/polls_helper.rb @@ -28,11 +28,6 @@ module PollsHelper options_for_select(options, params[:d]) end - def poll_final_recount_option(poll) - final_date = poll.ends_at.to_date + 1.day - options_for_select([[I18n.t("polls.final_date"), l(final_date)]]) - end - def poll_booths_select_options(poll) options = [] poll.booths.each do |booth| @@ -46,4 +41,4 @@ module PollsHelper booth.name + location end -end \ No newline at end of file +end From a3bf69e78deba4a0ae7b39addf8f8fe3ff5d2cb0 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Tue, 19 Sep 2017 01:13:01 +0200 Subject: [PATCH 006/161] Remove final result usage on admin poll officer assignments results --- .../poll/booth_assignments_controller.rb | 2 +- .../poll/officer_assignments_controller.rb | 2 +- .../admin/poll/recounts_controller.rb | 2 +- app/models/poll/booth_assignment.rb | 1 - app/models/poll/officer_assignment.rb | 4 +++- .../officer_assignments/by_officer.html.erb | 12 ++++++------ app/views/officing/_menu.html.erb | 4 ++-- config/locales/en/admin.yml | 4 ++-- config/locales/en/officing.yml | 2 +- config/locales/es/admin.yml | 4 ++-- config/locales/es/officing.yml | 2 +- config/locales/fr/admin.yml | 4 ++-- config/locales/fr/officing.yml | 19 +------------------ config/locales/nl/admin.yml | 4 ++-- config/locales/nl/officing.yml | 19 +------------------ 15 files changed, 26 insertions(+), 59 deletions(-) diff --git a/app/controllers/admin/poll/booth_assignments_controller.rb b/app/controllers/admin/poll/booth_assignments_controller.rb index 358f26a65..e8f7b9134 100644 --- a/app/controllers/admin/poll/booth_assignments_controller.rb +++ b/app/controllers/admin/poll/booth_assignments_controller.rb @@ -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 diff --git a/app/controllers/admin/poll/officer_assignments_controller.rb b/app/controllers/admin/poll/officer_assignments_controller.rb index 45c9a225a..b7068977b 100644 --- a/app/controllers/admin/poll/officer_assignments_controller.rb +++ b/app/controllers/admin/poll/officer_assignments_controller.rb @@ -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 diff --git a/app/controllers/admin/poll/recounts_controller.rb b/app/controllers/admin/poll/recounts_controller.rb index 57289a207..082343e31 100644 --- a/app/controllers/admin/poll/recounts_controller.rb +++ b/app/controllers/admin/poll/recounts_controller.rb @@ -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 diff --git a/app/models/poll/booth_assignment.rb b/app/models/poll/booth_assignment.rb index 47cb01bfe..8b4b655ef 100644 --- a/app/models/poll/booth_assignment.rb +++ b/app/models/poll/booth_assignment.rb @@ -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 diff --git a/app/models/poll/officer_assignment.rb b/app/models/poll/officer_assignment.rb index 1d7326500..8e86d309c 100644 --- a/app/models/poll/officer_assignment.rb +++ b/app/models/poll/officer_assignment.rb @@ -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 diff --git a/app/views/admin/poll/officer_assignments/by_officer.html.erb b/app/views/admin/poll/officer_assignments/by_officer.html.erb index 8cc6c0437..afc674769 100644 --- a/app/views/admin/poll/officer_assignments/by_officer.html.erb +++ b/app/views/admin/poll/officer_assignments/by_officer.html.erb @@ -31,23 +31,23 @@ <% final_officer_assignments = @officer_assignments.select{|oa| oa.final == true} %> <% if final_officer_assignments.any? %> -

<%= t("admin.poll_officer_assignments.by_officer.final_recounts") %>

- +

<%= t("admin.poll_officer_assignments.by_officer.total_recounts") %>

+
- + <% final_officer_assignments.each do |officer_assignment| %> - +
<%= t("admin.poll_officer_assignments.by_officer.date") %> <%= t("admin.poll_officer_assignments.by_officer.booth") %><%= t("admin.poll_officer_assignments.by_officer.final_recount") %><%= t("admin.poll_officer_assignments.by_officer.total_recount") %>
<%= l(officer_assignment.date.to_date) %> <%= booth_name_with_location(officer_assignment.booth_assignment.booth) %> - <% 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 %> - <% end %> diff --git a/app/views/officing/_menu.html.erb b/app/views/officing/_menu.html.erb index 1f8c2c56d..c96fd8c07 100644 --- a/app/views/officing/_menu.html.erb +++ b/app/views/officing/_menu.html.erb @@ -8,10 +8,10 @@ <% end %> -
  • > +
  • > <%= link_to final_officing_polls_path do %> - <%= t("officing.menu.final_recounts") %> + <%= t("officing.menu.total_recounts") %> <% end %>
  • diff --git a/config/locales/en/admin.yml b/config/locales/en/admin.yml index 63fb7c70c..d9b91b01c 100644 --- a/config/locales/en/admin.yml +++ b/config/locales/en/admin.yml @@ -494,8 +494,8 @@ en: booth: "Booth" assignments: "Officing shifts in this poll" no_assignments: "This user has no officing shifts in this poll." - final_recounts: "Final recounts" - final_recount: "Final recount (by officer)" + total_recounts: "Total recounts" + total_recount: "Total recount (by officer)" poll_shifts: new: add_shift: "Add shift" diff --git a/config/locales/en/officing.yml b/config/locales/en/officing.yml index 72b3812ea..2dfc29ac3 100644 --- a/config/locales/en/officing.yml +++ b/config/locales/en/officing.yml @@ -9,7 +9,7 @@ en: info: Here you can validate user documents and store voting results menu: voters: Validate document - final_recounts: Final recounts and results + total_recounts: Total recounts and results polls: final: title: Polls ready for final recounting diff --git a/config/locales/es/admin.yml b/config/locales/es/admin.yml index 0e1f0db65..5f8c73341 100644 --- a/config/locales/es/admin.yml +++ b/config/locales/es/admin.yml @@ -494,8 +494,8 @@ es: booth: "Urna" assignments: "Turnos como presidente de mesa en esta votación" no_assignments: "No tiene turnos como presidente de mesa en esta votación." - final_recounts: "Recuentos finales" - final_recount: "Recuento final (presidente de mesa)" + total_recounts: "Recuentos totales" + total_recount: "Recuento total (presidente de mesa)" poll_shifts: new: add_shift: "Añadir turno" diff --git a/config/locales/es/officing.yml b/config/locales/es/officing.yml index 81dd70492..74358ab56 100644 --- a/config/locales/es/officing.yml +++ b/config/locales/es/officing.yml @@ -9,7 +9,7 @@ es: info: Aquí puedes validar documentos de ciudadanos y guardar los resultados de las urnas menu: voters: "Validar documento y votar" - final_recounts: "Recuento final y escrutinio" + total_recounts: "Recuento total y escrutinio" polls: final: title: "Listado de votaciones finalizadas" diff --git a/config/locales/fr/admin.yml b/config/locales/fr/admin.yml index 966563b7c..ae9a44277 100644 --- a/config/locales/fr/admin.yml +++ b/config/locales/fr/admin.yml @@ -301,8 +301,8 @@ fr: no_assignments: "Cet utilisateur n'a pas d'affectation pour ce vote." recounts: "Dépouillement journalier" recount: "Dépouillement journalier (par président)" - final_recounts: "Dépouillement final" - final_recount: "Dépouillement final (par président)" + total_recounts: "Dépouillement final" + total_recount: "Dépouillement final (par président)" poll_booth_assignments: flash: destroy: "Ce bureau de vote n'est plus affecté" diff --git a/config/locales/fr/officing.yml b/config/locales/fr/officing.yml index c0e3d4284..c660b49f1 100644 --- a/config/locales/fr/officing.yml +++ b/config/locales/fr/officing.yml @@ -10,7 +10,7 @@ fr: menu: voters: "Valider un document" recounts: "Enregistrer le dépouillement" - final_recounts: "Dépouillements finaux et résultats" + total_recounts: "Dépouillements finaux et résultats" polls: index: title: "Liste des votes" @@ -38,23 +38,6 @@ fr: recount_list: "Vos dépouillements" booth: "Urne" date: "Date" - final_recounts: - flash: - create: "Données ajoutées" - error_create: "Décompte final NON ajouté. Erreur dans les données." - new: - title: "%{poll} - Ajouter le dépouillement final" - not_allowed: "Vous n'êtes pas autorisés à ajouter les dépouillements finaux pour ce vote" - booth: "Bureau de vote" - date: "Date" - select_booth: "Sélectionner un bureau de vote" - select_date: "Sélectionner une date" - count: "Décompte final des votes" - count_placeholder: "Décompte final des votes" - submit: "Sauvegarder" - final_recount_list: "Vos dépouillements finaux" - system_count: "Dépouillement par le système" - add_results: "Ajouter les résultats" results: flash: create: "Résultats sauvegardés" diff --git a/config/locales/nl/admin.yml b/config/locales/nl/admin.yml index c7d77cda9..8a30b0d21 100644 --- a/config/locales/nl/admin.yml +++ b/config/locales/nl/admin.yml @@ -301,8 +301,8 @@ nl: no_assignments: "This user has no officing shifts in this poll." recounts: "Daily recounts" recount: "Daily recount (by officer)" - final_recounts: "Final recounts" - final_recount: "Final recount (by officer)" + total_recounts: "Final recounts" + total_recount: "Final recount (by officer)" poll_booth_assignments: flash: destroy: "Booth not assigned anymore" diff --git a/config/locales/nl/officing.yml b/config/locales/nl/officing.yml index 08be19335..810a354b5 100644 --- a/config/locales/nl/officing.yml +++ b/config/locales/nl/officing.yml @@ -10,7 +10,7 @@ nl: menu: voters: Validate document recounts: Store recount - final_recounts: Final recounts and results + total_recounts: Final recounts and results polls: index: title: Poll list @@ -38,23 +38,6 @@ nl: recount_list: "Your recounts" booth: "Booth" date: "Date" - final_recounts: - flash: - create: "Data added" - error_create: "Final counts NOT added. Error in data." - new: - title: "%{poll} - Add final recount" - not_allowed: "You are allowed to add final recounts for this poll" - booth: "Booth" - date: "Date" - select_booth: "Select booth" - select_date: "Select date" - count: "Final vote count" - count_placeholder: "Final vote count" - submit: Save - final_recount_list: "Your final recounts" - system_count: "System recount" - add_results: "Add results" results: flash: create: "Results saved" From 2e3b5aad49f037213089f11603e8cdfc1be72c2c Mon Sep 17 00:00:00 2001 From: Bertocq Date: Tue, 19 Sep 2017 01:22:30 +0200 Subject: [PATCH 007/161] Totally remove Poll::FinalRecount model, table spec and factory --- .rubocop_todo.yml | 1 - app/models/poll/final_recount.rb | 19 --------- ...170918231410_remove_poll_final_recounts.rb | 11 +++++ db/schema.rb | 18 +-------- spec/factories.rb | 7 ---- spec/models/poll/final_recount_spec.rb | 40 ------------------- 6 files changed, 12 insertions(+), 84 deletions(-) delete mode 100644 app/models/poll/final_recount.rb create mode 100644 db/migrate/20170918231410_remove_poll_final_recounts.rb delete mode 100644 spec/models/poll/final_recount_spec.rb diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 4704696e5..288c964c1 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -283,7 +283,6 @@ Lint/ParenthesesAsGroupedExpression: # Cop supports --auto-correct. Lint/StringConversionInInterpolation: Exclude: - - 'app/models/poll/final_recount.rb' - 'app/models/poll/null_result.rb' - 'app/models/poll/partial_result.rb' - 'app/models/poll/white_result.rb' diff --git a/app/models/poll/final_recount.rb b/app/models/poll/final_recount.rb deleted file mode 100644 index 3647c85ca..000000000 --- a/app/models/poll/final_recount.rb +++ /dev/null @@ -1,19 +0,0 @@ -class Poll - class FinalRecount < ActiveRecord::Base - belongs_to :booth_assignment, class_name: "Poll::BoothAssignment" - belongs_to :officer_assignment, class_name: "Poll::OfficerAssignment" - - validates :booth_assignment_id, presence: true - validates :date, presence: true, uniqueness: {scope: :booth_assignment_id} - validates :count, presence: true, numericality: {only_integer: true} - - before_save :update_logs - - def update_logs - if count_changed? && count_was.present? - self.count_log += ":#{count_was.to_s}" - self.officer_assignment_id_log += ":#{officer_assignment_id_was.to_s}" - end - end - end -end \ No newline at end of file diff --git a/db/migrate/20170918231410_remove_poll_final_recounts.rb b/db/migrate/20170918231410_remove_poll_final_recounts.rb new file mode 100644 index 000000000..369a959bb --- /dev/null +++ b/db/migrate/20170918231410_remove_poll_final_recounts.rb @@ -0,0 +1,11 @@ +class RemovePollFinalRecounts < ActiveRecord::Migration + def change + remove_index :poll_final_recounts, column: :booth_assignment_id + remove_index :poll_final_recounts, column: :officer_assignment_id + + remove_foreign_key :poll_final_recounts, column: "booth_assignment_id" + remove_foreign_key :poll_final_recounts, column: "officer_assignment_id" + + drop_table :poll_final_recounts + end +end diff --git a/db/schema.rb b/db/schema.rb index 45598ff4e..240abcdaa 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: 20170914154743) do +ActiveRecord::Schema.define(version: 20170918231410) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -586,20 +586,6 @@ ActiveRecord::Schema.define(version: 20170914154743) do t.string "location" end - create_table "poll_final_recounts", force: :cascade do |t| - t.integer "booth_assignment_id" - t.integer "officer_assignment_id" - t.integer "count" - t.text "count_log", default: "" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.text "officer_assignment_id_log", default: "" - t.date "date", null: false - end - - add_index "poll_final_recounts", ["booth_assignment_id"], name: "index_poll_final_recounts_on_booth_assignment_id", using: :btree - add_index "poll_final_recounts", ["officer_assignment_id"], name: "index_poll_final_recounts_on_officer_assignment_id", using: :btree - create_table "poll_null_results", force: :cascade do |t| t.integer "author_id" t.integer "amount" @@ -1101,8 +1087,6 @@ ActiveRecord::Schema.define(version: 20170914154743) do add_foreign_key "organizations", "users" add_foreign_key "poll_answers", "poll_questions", column: "question_id" add_foreign_key "poll_booth_assignments", "polls" - add_foreign_key "poll_final_recounts", "poll_booth_assignments", column: "booth_assignment_id" - add_foreign_key "poll_final_recounts", "poll_officer_assignments", column: "officer_assignment_id" add_foreign_key "poll_null_results", "poll_booth_assignments", column: "booth_assignment_id" add_foreign_key "poll_null_results", "poll_officer_assignments", column: "officer_assignment_id" add_foreign_key "poll_officer_assignments", "poll_booth_assignments", column: "booth_assignment_id" diff --git a/spec/factories.rb b/spec/factories.rb index b1c6e7174..b90f68175 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -507,13 +507,6 @@ FactoryGirl.define do date Date.current end - factory :poll_final_recount, class: 'Poll::FinalRecount' do - association :officer_assignment, factory: [:poll_officer_assignment, :final] - association :booth_assignment, factory: :poll_booth_assignment - count (1..100).to_a.sample - date (1.month.ago.to_datetime..1.month.from_now.to_datetime).to_a.sample - end - factory :poll_voter, class: 'Poll::Voter' do poll association :user, :level_two diff --git a/spec/models/poll/final_recount_spec.rb b/spec/models/poll/final_recount_spec.rb deleted file mode 100644 index bccd772ca..000000000 --- a/spec/models/poll/final_recount_spec.rb +++ /dev/null @@ -1,40 +0,0 @@ -require 'rails_helper' - -describe :final_recount do - - it "should update count_log if count changes" do - final_recount = create(:poll_final_recount, count: 33) - - expect(final_recount.count_log).to eq("") - - final_recount.count = 33 - final_recount.save - final_recount.count = 32 - final_recount.save - final_recount.count = 34 - final_recount.save - - expect(final_recount.count_log).to eq(":33:32") - end - - it "should update officer_assignment_id_log if count changes" do - final_recount = create(:poll_final_recount, count: 33) - - expect(final_recount.count_log).to eq("") - - final_recount.count = 33 - final_recount.officer_assignment = create(:poll_officer_assignment, id: 111) - final_recount.save - - final_recount.count = 32 - final_recount.officer_assignment = create(:poll_officer_assignment, id: 112) - final_recount.save - - final_recount.count = 34 - final_recount.officer_assignment = create(:poll_officer_assignment, id: 113) - final_recount.save - - expect(final_recount.officer_assignment_id_log).to eq(":111:112") - end - -end \ No newline at end of file From 630a3252b7ddd5b7d3e4a08af011f5ef7ee388f8 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Tue, 19 Sep 2017 01:38:02 +0200 Subject: [PATCH 008/161] Fix admin poll officers assignments by officer view --- .../admin/poll/officer_assignments/by_officer.html.erb | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/app/views/admin/poll/officer_assignments/by_officer.html.erb b/app/views/admin/poll/officer_assignments/by_officer.html.erb index afc674769..6ea421e2d 100644 --- a/app/views/admin/poll/officer_assignments/by_officer.html.erb +++ b/app/views/admin/poll/officer_assignments/by_officer.html.erb @@ -27,10 +27,7 @@ <% end %>
    -<% end %> -<% final_officer_assignments = @officer_assignments.select{|oa| oa.final == true} %> -<% if final_officer_assignments.any? %>

    <%= t("admin.poll_officer_assignments.by_officer.total_recounts") %>

    @@ -41,13 +38,13 @@ - <% final_officer_assignments.each do |officer_assignment| %> + <% @officer_assignments.each do |officer_assignment| %>
    <%= l(officer_assignment.date.to_date) %> <%= booth_name_with_location(officer_assignment.booth_assignment.booth) %> - <% if officer_assignment.total_recounts.any? %> - <%= officer_assignment.total_recounts.to_a.sum(&:amount) %> + <% if officer_assignment.total_results.any? %> + <%= officer_assignment.total_results.to_a.sum(&:amount) %> <% else %> - <% end %> From 6e3f9f9b324147853d8949cfabb981cf9546ce30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sen=C3=A9n=20Rodero=20Rodr=C3=ADguez?= Date: Mon, 11 Sep 2017 14:39:58 +0200 Subject: [PATCH 009/161] Remove document cached_attachment value after destroy_upload action. --- app/controllers/documents_controller.rb | 1 + spec/shared/features/documentable.rb | 35 +++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/app/controllers/documents_controller.rb b/app/controllers/documents_controller.rb index a48f182ab..8f085e27f 100644 --- a/app/controllers/documents_controller.rb +++ b/app/controllers/documents_controller.rb @@ -48,6 +48,7 @@ class DocumentsController < ApplicationController def destroy_upload @document = Document.new(cached_attachment: params[:path]) @document.set_attachment_from_cached_attachment + @document.cached_attachment = nil @document.documentable = @documentable if @document.attachment.destroy diff --git a/spec/shared/features/documentable.rb b/spec/shared/features/documentable.rb index e9a82c63c..9c31da7b0 100644 --- a/spec/shared/features/documentable.rb +++ b/spec/shared/features/documentable.rb @@ -251,6 +251,41 @@ shared_examples "documentable" do |documentable_factory_name, documentable_path, expect(find("input[name='document[cached_attachment]']", visible: false).value).to include("empty.pdf") end + scenario "Should not show 'Choose document' button after valid upload", :js do + login_as documentable.author + visit new_document_path(documentable_type: documentable.class.name, + documentable_id: documentable.id) + + attach_file :document_attachment, "spec/fixtures/files/empty.pdf", make_visible: true + sleep 1 + + expect(page).not_to have_content "Choose document" + end + + scenario "Should show 'Remove document' button after valid upload", :js do + login_as documentable.author + visit new_document_path(documentable_type: documentable.class.name, + documentable_id: documentable.id) + + attach_file :document_attachment, "spec/fixtures/files/empty.pdf", make_visible: true + sleep 1 + + expect(page).to have_link("Remove document") + end + + scenario "Should show 'Choose document' button after remove valid upload", :js do + login_as documentable.author + visit new_document_path(documentable_type: documentable.class.name, + documentable_id: documentable.id) + + attach_file :document_attachment, "spec/fixtures/files/empty.pdf", make_visible: true + sleep 1 + click_link "Remove document" + sleep 1 + + expect(page).to have_content "Choose document" + end + scenario "Should not update document cached_attachment field after unvalid file upload", :js do login_as documentable.author visit new_document_path(documentable_type: documentable.class.name, From 6082147571fc263e32425e3e380f5c0d16ff1608 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Thu, 14 Sep 2017 23:15:19 +0200 Subject: [PATCH 010/161] Use snake_case for method names --- app/helpers/documentables_helper.rb | 4 ++-- app/helpers/documents_helper.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/helpers/documentables_helper.rb b/app/helpers/documentables_helper.rb index a4a840785..edbf88131 100644 --- a/app/helpers/documentables_helper.rb +++ b/app/helpers/documentables_helper.rb @@ -9,7 +9,7 @@ module DocumentablesHelper end def max_file_size(documentable) - bytesToMeg(documentable.class.max_file_size) + bytes_to_mega(documentable.class.max_file_size) end def accepted_content_types(documentable) @@ -38,4 +38,4 @@ module DocumentablesHelper documentable.documents.count >= documentable.class.max_documents_allowed end -end \ No newline at end of file +end diff --git a/app/helpers/documents_helper.rb b/app/helpers/documents_helper.rb index a8ae6c973..72ebbf021 100644 --- a/app/helpers/documents_helper.rb +++ b/app/helpers/documents_helper.rb @@ -8,7 +8,7 @@ module DocumentsHelper document.errors[:attachment].join(', ') if document.errors.key?(:attachment) end - def bytesToMeg(bytes) + def bytes_to_mega(bytes) bytes / Numeric::MEGABYTE end From c5671ed4622bd2017ca25d72cac36565415168a9 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Thu, 14 Sep 2017 23:17:41 +0200 Subject: [PATCH 011/161] Use correct Predicate name on function --- app/helpers/communities_helper.rb | 2 +- app/views/communities/_participant.html.erb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/helpers/communities_helper.rb b/app/helpers/communities_helper.rb index bb770a948..22bc76617 100644 --- a/app/helpers/communities_helper.rb +++ b/app/helpers/communities_helper.rb @@ -12,7 +12,7 @@ module CommunitiesHelper community.from_proposal? ? t("community.show.description.proposal") : t("community.show.description.investment") end - def is_author?(community, participant) + def author?(community, participant) if community.from_proposal? community.proposal.author_id == participant.id else diff --git a/app/views/communities/_participant.html.erb b/app/views/communities/_participant.html.erb index 5e4f02900..91f991383 100644 --- a/app/views/communities/_participant.html.erb +++ b/app/views/communities/_participant.html.erb @@ -9,7 +9,7 @@ <%= link_to participant.name, user_path(participant)%> - <% if is_author?(@community, participant) %> + <% if author?(@community, participant) %>  •  <%= t("comments.comment.author") %> From d9575baaab1d371b34742d18bc9205cda8255f7a Mon Sep 17 00:00:00 2001 From: Bertocq Date: Thu, 14 Sep 2017 23:18:48 +0200 Subject: [PATCH 012/161] Correct end at file ending --- app/models/poll/shift.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/poll/shift.rb b/app/models/poll/shift.rb index 37a8658f3..d894df5a4 100644 --- a/app/models/poll/shift.rb +++ b/app/models/poll/shift.rb @@ -26,4 +26,4 @@ class Poll end end - end \ No newline at end of file +end From bf37b8e5f90b6b6f223b00f8e4280ef3ff519480 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Thu, 14 Sep 2017 23:23:10 +0200 Subject: [PATCH 013/161] Use datetime always with zone --- spec/features/admin/poll/shifts_spec.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/features/admin/poll/shifts_spec.rb b/spec/features/admin/poll/shifts_spec.rb index 65396267b..1e5bb6328 100644 --- a/spec/features/admin/poll/shifts_spec.rb +++ b/spec/features/admin/poll/shifts_spec.rb @@ -14,19 +14,19 @@ feature 'Admin shifts' do booth1 = create(:poll_booth) booth2 = create(:poll_booth) - shift1 = create(:poll_shift, officer: officer, booth: booth1, date: Date.today) - shift2 = create(:poll_shift, officer: officer, booth: booth2, date: Date.tomorrow) + shift1 = create(:poll_shift, officer: officer, booth: booth1, date: Time.zone.today) + shift2 = create(:poll_shift, officer: officer, booth: booth2, date: Time.zone.tomorrow) visit new_admin_booth_shift_path(booth1) expect(page).to have_css(".shift", count: 1) - expect(page).to have_content I18n.l(Date.today, format: :long) + expect(page).to have_content I18n.l(Time.zone.today, format: :long) expect(page).to have_content officer.name visit new_admin_booth_shift_path(booth2) expect(page).to have_css(".shift", count: 1) - expect(page).to have_content I18n.l(Date.tomorrow, format: :long) + expect(page).to have_content I18n.l(Time.zone.tomorrow, format: :long) expect(page).to have_content officer.name end From adc71faf1c03d93e0c2ce480743c9417f01930e1 Mon Sep 17 00:00:00 2001 From: decabeza Date: Mon, 18 Sep 2017 14:21:38 +0200 Subject: [PATCH 014/161] moves author actions to sidebar on proposal show --- app/assets/stylesheets/participation.scss | 10 ++++- app/helpers/proposals_helper.rb | 16 ++++++++ app/views/proposals/show.html.erb | 47 ++++++++++++++--------- config/locales/en/general.yml | 1 + config/locales/es/general.yml | 1 + 5 files changed, 55 insertions(+), 20 deletions(-) diff --git a/app/assets/stylesheets/participation.scss b/app/assets/stylesheets/participation.scss index 84e80f01f..8c380caf1 100644 --- a/app/assets/stylesheets/participation.scss +++ b/app/assets/stylesheets/participation.scss @@ -395,8 +395,6 @@ } } - &.tags, - &.geozone { li { margin-bottom: 0; @@ -610,6 +608,14 @@ } } +.show-actions-menu { + + [class^="icon-"] { + display: inline-block; + vertical-align: middle; + } +} + // 04. List participation // ---------------------- diff --git a/app/helpers/proposals_helper.rb b/app/helpers/proposals_helper.rb index 37425d573..f6060603f 100644 --- a/app/helpers/proposals_helper.rb +++ b/app/helpers/proposals_helper.rb @@ -32,4 +32,20 @@ module ProposalsHelper Proposal::RETIRE_OPTIONS.collect { |option| [ t("proposals.retire_options.#{option}"), option ] } end + def can_create_document? + can?(:create, @document) && @proposal.documents.size < Proposal.max_documents_allowed + end + + def author_of_proposal? + author_of?(@proposal, current_user) + end + + def current_editable? + current_user && @proposal.editable_by?(current_user) + end + + def show_actions_menu? + can_create_document? || author_of_proposal? || current_editable? + end + end \ No newline at end of file diff --git a/app/views/proposals/show.html.erb b/app/views/proposals/show.html.erb index 1dc918e8e..46db56ce6 100644 --- a/app/views/proposals/show.html.erb +++ b/app/views/proposals/show.html.erb @@ -16,24 +16,6 @@
    <%= back_link_to %> - <% if can?(:create, @document) && @proposal.documents.size < Proposal.max_documents_allowed %> - <%= link_to t("documents.upload_document"), - new_document_path(documentable_id: @proposal, documentable_type: @proposal.class.name, from: request.url), - class: 'button hollow float-right' %> - <% end %> - - <% if author_of?(@proposal, current_user) %> - <%= link_to t("proposals.show.send_notification"), - new_proposal_notification_path(proposal_id: @proposal.id), - class: 'button hollow float-right' %> - <% end %> - - <% if current_user && @proposal.editable_by?(current_user) %> - <%= link_to edit_proposal_path(@proposal), class: 'edit-proposal button hollow float-right' do %> - <%= t("proposals.show.edit_proposal_link") %> - <% end %> - <% end %> -

    <%= @proposal.title %>

    <% if @proposal.retired? %>
    @@ -122,6 +104,35 @@