From ff8cc2d7bdc5cfbbe256183d423953223bf174ed Mon Sep 17 00:00:00 2001 From: Juanma Date: Mon, 9 Jan 2017 16:07:59 +0100 Subject: [PATCH 01/26] Fixes values of official_level options for selects in search filters. --- app/helpers/search_helper.rb | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/app/helpers/search_helper.rb b/app/helpers/search_helper.rb index 3d30ce101..ebde2a954 100644 --- a/app/helpers/search_helper.rb +++ b/app/helpers/search_helper.rb @@ -1,13 +1,8 @@ module SearchHelper def official_level_search_options - options_for_select([ - [t("shared.advanced_search.author_type_1"), 1], - [t("shared.advanced_search.author_type_2"), 2], - [t("shared.advanced_search.author_type_3"), 3], - [t("shared.advanced_search.author_type_4"), 4], - [t("shared.advanced_search.author_type_5"), 5]], - params[:advanced_search].try(:[], :official_level)) + options_for_select((1..5).map{ |i| [setting["official_level_#{i}_name"], i] }, + params[:advanced_search].try(:[], :official_level)) end def date_range_options @@ -28,4 +23,4 @@ module SearchHelper params[:advanced_search].try(:[], :date_max).present? end -end \ No newline at end of file +end From 5fe38f97202916794a4b5f2af06060ad09d80ccb Mon Sep 17 00:00:00 2001 From: Juanma Date: Mon, 9 Jan 2017 16:25:50 +0100 Subject: [PATCH 02/26] Removes translation texts. --- config/locales/en.yml | 5 ----- config/locales/es.yml | 5 ----- config/locales/fr.yml | 5 ----- config/locales/pt-BR.yml | 5 ----- 4 files changed, 20 deletions(-) diff --git a/config/locales/en.yml b/config/locales/en.yml index 3ae90565f..a76de20a0 100755 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -400,11 +400,6 @@ en: advanced_search: author_type: 'By author category' author_type_blank: 'Select a category' - author_type_1: 'Public employee' - author_type_2: 'Municipal Organization' - author_type_3: 'General director' - author_type_4: 'City councillor' - author_type_5: 'Mayoress' date: 'By date' date_placeholder: 'DD/MM/YYYY' date_range_blank: 'Choose a date' diff --git a/config/locales/es.yml b/config/locales/es.yml index 8d5dfb490..9ed65b79b 100755 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -400,11 +400,6 @@ es: advanced_search: author_type: 'Por categoría de autor' author_type_blank: 'Elige una categoría' - author_type_1: 'Empleado público' - author_type_2: 'Organización Municipal' - author_type_3: 'Director general' - author_type_4: 'Concejal' - author_type_5: 'Alcaldesa' date: 'Por fecha' date_placeholder: 'DD/MM/AAAA' date_range_blank: 'Elige una fecha' diff --git a/config/locales/fr.yml b/config/locales/fr.yml index b70c4648d..57b0c25e6 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -1361,11 +1361,6 @@ fr: shared: advanced_search: author_type: Par catégorie d'auteur - author_type_1: Fonctionnaire - author_type_2: Organisation municipale - author_type_3: Directeur général - author_type_4: Conseiller municipal - author_type_5: Maire author_type_blank: Sélectionner une catégorie date: Par date date_1: Dernières 24 heures diff --git a/config/locales/pt-BR.yml b/config/locales/pt-BR.yml index 831c9a556..441f20324 100644 --- a/config/locales/pt-BR.yml +++ b/config/locales/pt-BR.yml @@ -1383,11 +1383,6 @@ pt-BR: shared: advanced_search: author_type: Por categoria de autor - author_type_1: Servidor público - author_type_2: Organização municipal - author_type_3: Diretor geral - author_type_4: Conselheiro municipal - author_type_5: Prefeita author_type_blank: Selecione um categoria date: Por data date_1: "Últimas 24 horas" From fcebfe4440429073a6d6be774e75dcd833ddfbaa Mon Sep 17 00:00:00 2001 From: Juanma Date: Tue, 10 Jan 2017 12:34:02 +0100 Subject: [PATCH 03/26] Fixes specs. --- spec/features/proposals_spec.rb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/spec/features/proposals_spec.rb b/spec/features/proposals_spec.rb index 7a99b0050..72bd5ea7b 100644 --- a/spec/features/proposals_spec.rb +++ b/spec/features/proposals_spec.rb @@ -873,7 +873,7 @@ feature 'Proposals' do visit proposals_path click_link "Advanced search" - select "Public employee", from: "advanced_search_official_level" + select Setting['official_level_1_name'], from: "advanced_search_official_level" click_button "Filter" expect(page).to have_content("There are 2 citizen proposals") @@ -896,7 +896,7 @@ feature 'Proposals' do visit proposals_path click_link "Advanced search" - select "Municipal Organization", from: "advanced_search_official_level" + select Setting['official_level_2_name'], from: "advanced_search_official_level" click_button "Filter" expect(page).to have_content("There are 2 citizen proposals") @@ -919,7 +919,7 @@ feature 'Proposals' do visit proposals_path click_link "Advanced search" - select "General director", from: "advanced_search_official_level" + select Setting['official_level_3_name'], from: "advanced_search_official_level" click_button "Filter" expect(page).to have_content("There are 2 citizen proposals") @@ -942,7 +942,7 @@ feature 'Proposals' do visit proposals_path click_link "Advanced search" - select "City councillor", from: "advanced_search_official_level" + select Setting['official_level_4_name'], from: "advanced_search_official_level" click_button "Filter" expect(page).to have_content("There are 2 citizen proposals") @@ -965,7 +965,7 @@ feature 'Proposals' do visit proposals_path click_link "Advanced search" - select "Mayoress", from: "advanced_search_official_level" + select Setting['official_level_5_name'], from: "advanced_search_official_level" click_button "Filter" expect(page).to have_content("There are 2 citizen proposals") @@ -1099,7 +1099,7 @@ feature 'Proposals' do click_link "Advanced search" fill_in "Write the text", with: "Schwifty" - select "Public employee", from: "advanced_search_official_level" + select Setting['official_level_1_name'], from: "advanced_search_official_level" select "Last 24 hours", from: "js-advanced-search-date-min" click_button "Filter" @@ -1116,7 +1116,7 @@ feature 'Proposals' do click_link "Advanced search" fill_in "Write the text", with: "Schwifty" - select "Public employee", from: "advanced_search_official_level" + select Setting['official_level_1_name'], from: "advanced_search_official_level" select "Last 24 hours", from: "js-advanced-search-date-min" click_button "Filter" @@ -1125,7 +1125,7 @@ feature 'Proposals' do within "#js-advanced-search" do expect(page).to have_selector("input[name='search'][value='Schwifty']") - expect(page).to have_select('advanced_search[official_level]', selected: 'Public employee') + expect(page).to have_select('advanced_search[official_level]', selected: Setting['official_level_1_name']) expect(page).to have_select('advanced_search[date_min]', selected: 'Last 24 hours') end end From 68b2f6d9c4a03a92c726fc9076fae52bcf110778 Mon Sep 17 00:00:00 2001 From: Juanma Date: Fri, 13 Jan 2017 07:44:57 +0100 Subject: [PATCH 04/26] Fixes specs. --- spec/features/debates_spec.rb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/spec/features/debates_spec.rb b/spec/features/debates_spec.rb index 1ded2e0ff..b509b6ccf 100644 --- a/spec/features/debates_spec.rb +++ b/spec/features/debates_spec.rb @@ -515,7 +515,7 @@ feature 'Debates' do visit debates_path click_link "Advanced search" - select "Public employee", from: "advanced_search_official_level" + select Setting['official_level_1_name'], from: "advanced_search_official_level" click_button "Filter" expect(page).to have_content("There are 2 debates") @@ -538,7 +538,7 @@ feature 'Debates' do visit debates_path click_link "Advanced search" - select "Municipal Organization", from: "advanced_search_official_level" + select Setting['official_level_2_name'], from: "advanced_search_official_level" click_button "Filter" expect(page).to have_content("There are 2 debates") @@ -561,7 +561,7 @@ feature 'Debates' do visit debates_path click_link "Advanced search" - select "General director", from: "advanced_search_official_level" + select Setting['official_level_3_name'], from: "advanced_search_official_level" click_button "Filter" expect(page).to have_content("There are 2 debates") @@ -584,7 +584,7 @@ feature 'Debates' do visit debates_path click_link "Advanced search" - select "City councillor", from: "advanced_search_official_level" + select Setting['official_level_4_name'], from: "advanced_search_official_level" click_button "Filter" expect(page).to have_content("There are 2 debates") @@ -607,7 +607,7 @@ feature 'Debates' do visit debates_path click_link "Advanced search" - select "Mayoress", from: "advanced_search_official_level" + select Setting['official_level_5_name'], from: "advanced_search_official_level" click_button "Filter" expect(page).to have_content("There are 2 debates") @@ -741,7 +741,7 @@ feature 'Debates' do click_link "Advanced search" fill_in "Write the text", with: "Schwifty" - select "Public employee", from: "advanced_search_official_level" + select Setting['official_level_1_name'], from: "advanced_search_official_level" select "Last 24 hours", from: "js-advanced-search-date-min" click_button "Filter" @@ -757,14 +757,14 @@ feature 'Debates' do click_link "Advanced search" fill_in "Write the text", with: "Schwifty" - select "Public employee", from: "advanced_search_official_level" + select Setting['official_level_1_name'], from: "advanced_search_official_level" select "Last 24 hours", from: "js-advanced-search-date-min" click_button "Filter" within "#js-advanced-search" do expect(page).to have_selector("input[name='search'][value='Schwifty']") - expect(page).to have_select('advanced_search[official_level]', selected: 'Public employee') + expect(page).to have_select('advanced_search[official_level]', selected: Setting['official_level_1_name']) expect(page).to have_select('advanced_search[date_min]', selected: 'Last 24 hours') end end From 119061bd4c2f4baca4354a063feb1f48adec6cdb Mon Sep 17 00:00:00 2001 From: Juanma Date: Fri, 13 Jan 2017 09:40:33 +0100 Subject: [PATCH 05/26] Fixes bug. Compiles all locales for ckeditor. --- config/initializers/ckeditor.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/initializers/ckeditor.rb b/config/initializers/ckeditor.rb index 58e119048..b3ef16d2d 100644 --- a/config/initializers/ckeditor.rb +++ b/config/initializers/ckeditor.rb @@ -1,4 +1,4 @@ Ckeditor.setup do |config| - config.assets_languages = I18n.available_locales.map(&:to_s) + config.assets_languages = Rails.application.config.i18n.available_locales.map{|l| l.to_s.downcase} config.assets_plugins = [] end From 470fe4158541c79b15790a03206be667deea8dcb Mon Sep 17 00:00:00 2001 From: rgarcia Date: Fri, 13 Jan 2017 11:13:01 +0100 Subject: [PATCH 06/26] only displays vote button in selecting phase --- app/models/budget/investment.rb | 2 +- spec/models/budget/investment_spec.rb | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/app/models/budget/investment.rb b/app/models/budget/investment.rb index 5389825e5..dd98e472e 100644 --- a/app/models/budget/investment.rb +++ b/app/models/budget/investment.rb @@ -199,7 +199,7 @@ class Budget end def should_show_votes? - budget.selecting? || budget.on_hold? + budget.selecting? end def should_show_ballots? diff --git a/spec/models/budget/investment_spec.rb b/spec/models/budget/investment_spec.rb index 0c6615a99..35839e560 100644 --- a/spec/models/budget/investment_spec.rb +++ b/spec/models/budget/investment_spec.rb @@ -65,6 +65,24 @@ describe Budget::Investment do end end + describe "#should_show_votes?" do + it "returns true in selecting phase" do + budget = create(:budget, phase: "selecting") + investment = create(:budget_investment, budget: budget) + + expect(investment.should_show_votes?).to eq(true) + end + + it "returns false in any other phase" do + Budget::PHASES.reject {|phase| phase == "selecting"}.each do |phase| + budget = create(:budget, phase: phase) + investment = create(:budget_investment, budget: budget) + + expect(investment.should_show_votes?).to eq(false) + end + end + end + describe "by_admin" do it "should return investments assigned to specific administrator" do investment1 = create(:budget_investment, administrator_id: 33) From dbf8b865183eeecd4a8411c9f3365a8df67a7480 Mon Sep 17 00:00:00 2001 From: rgarcia Date: Fri, 13 Jan 2017 11:37:06 +0100 Subject: [PATCH 07/26] fixes specs --- spec/features/budgets/votes_spec.rb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/spec/features/budgets/votes_spec.rb b/spec/features/budgets/votes_spec.rb index c31545428..e12d359cc 100644 --- a/spec/features/budgets/votes_spec.rb +++ b/spec/features/budgets/votes_spec.rb @@ -94,15 +94,13 @@ feature 'Votes' do visit budget_investments_path(budget, heading_id: heading.id) within("#budget_investment_#{investment.id}") do - find("div.js-participation").hover - expect(page).to have_content 'No Selecting Allowed' + expect(page).to_not have_css("budget_investment_#{investment.id}_votes") end visit budget_investment_path(budget, investment) within("#budget_investment_#{investment.id}") do - find("div.js-participation").hover - expect(page).to have_content 'No Selecting Allowed' + expect(page).to_not have_css("budget_investment_#{investment.id}_votes") end end end From e418937d426dd68085559173339d7d76fae22ef8 Mon Sep 17 00:00:00 2001 From: Juanma Date: Fri, 13 Jan 2017 11:49:23 +0100 Subject: [PATCH 08/26] Add custom setting for foundation variables. --- CUSTOMIZE_ES.md | 6 ++++++ app/assets/stylesheets/_custom_settings.scss | 5 +++++ app/assets/stylesheets/foundation_and_overrides.scss | 1 + 3 files changed, 12 insertions(+) create mode 100644 app/assets/stylesheets/_custom_settings.scss diff --git a/CUSTOMIZE_ES.md b/CUSTOMIZE_ES.md index 09fdfe62c..33c91b268 100644 --- a/CUSTOMIZE_ES.md +++ b/CUSTOMIZE_ES.md @@ -17,6 +17,7 @@ Para adaptarlo puedes hacerlo a través de los directorios que están en custom Aparte de estos directorios también cuentas con ciertos ficheros para: * `app/assets/stylesheets/custom.css` +* `app/assets/stylesheets/_custom_settings.css` * `app/assets/javascripts/custom.js` * `Gemfile_custom` * `config/application.custom.rb` @@ -67,6 +68,11 @@ Si quieres cambiar algun selector CSS (de las hojas de estilo) puedes hacerlo en background: red; } ``` +Si quieres cambiar alguna variable de foundation puedes hacerlo en el fichero `app/assets/stylesheets/_custom_settings.scss`. Por ejemplo para cambiar el color general de la aplicación puedes hacerlo agregando: + +```css +$brand: #446336; +``` Usamos un preprocesador de CSS, [SASS, con la sintaxis SCSS](http://sass-lang.com/guide). diff --git a/app/assets/stylesheets/_custom_settings.scss b/app/assets/stylesheets/_custom_settings.scss new file mode 100644 index 000000000..92a304e6f --- /dev/null +++ b/app/assets/stylesheets/_custom_settings.scss @@ -0,0 +1,5 @@ +// Overrides and adds customized foundation settings in this file +// Read more on documentation: +// * English: https://github.com/consul/consul/blob/master/CUSTOMIZE_EN.md#css +// * Spanish: https://github.com/consul/consul/blob/master/CUSTOMIZE_ES.md#css +// diff --git a/app/assets/stylesheets/foundation_and_overrides.scss b/app/assets/stylesheets/foundation_and_overrides.scss index 403d5566d..9387678f9 100644 --- a/app/assets/stylesheets/foundation_and_overrides.scss +++ b/app/assets/stylesheets/foundation_and_overrides.scss @@ -1,6 +1,7 @@ @charset 'utf-8'; @import 'settings'; +@import 'custom_settings'; @import 'foundation'; @include foundation-global-styles; From b2b9954e6d38755d06694326b5f2de7cedca037d Mon Sep 17 00:00:00 2001 From: rgarcia Date: Fri, 13 Jan 2017 15:24:57 +0100 Subject: [PATCH 09/26] allows user to support only in one heading per group --- .../budgets/investments_controller.rb | 4 ++ app/models/budget/investment.rb | 19 ++++++ app/models/user.rb | 4 ++ app/views/budgets/investments/_votes.html.erb | 4 +- config/locales/budgets.en.yml | 1 + config/locales/budgets.es.yml | 1 + spec/features/budgets/investments_spec.rb | 59 +++++++++++++++++++ spec/models/budget/investment_spec.rb | 12 ++++ 8 files changed, 102 insertions(+), 2 deletions(-) diff --git a/app/controllers/budgets/investments_controller.rb b/app/controllers/budgets/investments_controller.rb index 235163f2e..932d760b0 100644 --- a/app/controllers/budgets/investments_controller.rb +++ b/app/controllers/budgets/investments_controller.rb @@ -61,6 +61,10 @@ module Budgets def vote @investment.register_selection(current_user) load_investment_votes(@investment) + respond_to do |format| + format.html { redirect_to budget_investments_path(heading_id: @investment.heading.id) } + format.js + end end private diff --git a/app/models/budget/investment.rb b/app/models/budget/investment.rb index 5389825e5..d3485aad9 100644 --- a/app/models/budget/investment.rb +++ b/app/models/budget/investment.rb @@ -146,6 +146,7 @@ class Budget def reason_for_not_being_selectable_by(user) return permission_problem(user) if permission_problem?(user) + return :different_heading_assigned unless valid_heading?(user) return :no_selecting_allowed unless budget.selecting? end @@ -173,6 +174,24 @@ class Budget reason_for_not_being_selectable_by(user).blank? end + def valid_heading?(user) + !different_heading_assigned?(user) + end + + def different_heading_assigned?(user) + other_heading_ids = group.heading_ids - [heading.id] + voted_in?(other_heading_ids, user) + end + + def voted_in?(heading_ids, user) + heading_ids.include? heading_voted_by_user?(user) + end + + def heading_voted_by_user?(user) + user.votes.for_budget_investments(budget.investments.where(group: group)). + votables.map(&:heading_id).first + end + def ballotable_by?(user) reason_for_not_being_ballotable_by(user).blank? end diff --git a/app/models/user.rb b/app/models/user.rb index 881f5700d..f8991d676 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -103,6 +103,10 @@ class User < ActiveRecord::Base comment_flags.each_with_object({}){ |f, h| h[f.flaggable_id] = true } end + def voted_in_group?(group) + votes.for_budget_investments(Budget::Investment.where(group: group)).exists? + end + def administrator? administrator.present? end diff --git a/app/views/budgets/investments/_votes.html.erb b/app/views/budgets/investments/_votes.html.erb index 6d62b9a02..c2870d76c 100644 --- a/app/views/budgets/investments/_votes.html.erb +++ b/app/views/budgets/investments/_votes.html.erb @@ -14,12 +14,12 @@ <%= t("budgets.investments.investment.already_supported") %> <% elsif investment.should_show_votes? %> - <%= link_to vote_url, class: "button button-support small expanded", title: t('budgets.investments.investment.support_title'), method: "post", - remote: true, + remote: (current_user && current_user.voted_in_group?(investment.group) ? true : false), + data: (current_user && current_user.voted_in_group?(investment.group) ? nil : { confirm: t('budgets.investments.investment.confirm_group')} ), "aria-hidden" => css_for_aria_hidden(reason) do %> <%= t("budgets.investments.investment.give_support") %> <% end %> diff --git a/config/locales/budgets.en.yml b/config/locales/budgets.en.yml index 3ce0bb3ee..538681694 100644 --- a/config/locales/budgets.en.yml +++ b/config/locales/budgets.en.yml @@ -84,6 +84,7 @@ en: already_added: You have already added this investment project already_supported: You have already supported this. Share it! support_title: Support this project + confirm_group: "You can only support investments in one district. If you continue you cannot change your decision. Are you sure?" supports: one: 1 support other: "%{count} supports" diff --git a/config/locales/budgets.es.yml b/config/locales/budgets.es.yml index d558d5edd..db4c02949 100644 --- a/config/locales/budgets.es.yml +++ b/config/locales/budgets.es.yml @@ -84,6 +84,7 @@ es: already_added: "Ya has añadido esta propuesta de inversión" already_supported: Ya has apoyado esta propuesta. ¡Compártelo! support_title: Apoyar esta propuesta + confirm_group: "Sólo puedes apoyar propuestas en un distrito. Si sigues adelante no podrás cambiar esta decisión. ¿Estás seguro?" supports: one: 1 apoyo other: "%{count} apoyos" diff --git a/spec/features/budgets/investments_spec.rb b/spec/features/budgets/investments_spec.rb index 98540aa68..9f3a0cc66 100644 --- a/spec/features/budgets/investments_spec.rb +++ b/spec/features/budgets/investments_spec.rb @@ -288,6 +288,65 @@ feature 'Budget Investments' do end + context "Selecting Phase" do + + background do + budget.update(phase: "selecting") + end + + context "Popup alert to vote only in one heading per group" do + + scenario "When supporting in the first heading group", :js, :focus do + carabanchel = create(:budget_heading, group: group) + salamanca = create(:budget_heading, group: group) + + carabanchel_investment = create(:budget_investment, :selected, heading: carabanchel) + salamanca_investment = create(:budget_investment, :selected, heading: salamanca) + + visit budget_investments_path(budget, heading_id: carabanchel.id) + + within("#budget_investment_#{carabanchel_investment.id}") do + expect(page).to have_css(".in-favor a[data-confirm]") + end + end + + scenario "When already supported in the group", :js, :focus do + carabanchel = create(:budget_heading, group: group) + salamanca = create(:budget_heading, group: group) + + carabanchel_investment = create(:budget_investment, heading: carabanchel) + salamanca_investment = create(:budget_investment, heading: salamanca) + + create(:vote, votable: carabanchel_investment, voter: author) + + login_as(author) + visit budget_investments_path(budget, heading_id: carabanchel.id) + + within("#budget_investment_#{carabanchel_investment.id}") do + expect(page).to_not have_css(".in-favor a[data-confirm]") + end + end + + scenario "When supporting in another group", :js, :focus do + carabanchel = create(:budget_heading, group: group) + another_heading = create(:budget_heading, group: create(:budget_group, budget: budget)) + + carabanchel_investment = create(:budget_investment, heading: carabanchel) + another_group_investment = create(:budget_investment, heading: another_heading) + + create(:vote, votable: carabanchel_investment, voter: author) + + login_as(author) + visit budget_investments_path(budget, heading_id: another_heading.id) + + within("#budget_investment_#{another_group_investment.id}") do + expect(page).to have_css(".in-favor a[data-confirm]") + end + end + end + + end + context "Balloting Phase" do background do diff --git a/spec/models/budget/investment_spec.rb b/spec/models/budget/investment_spec.rb index 0c6615a99..e9fa58593 100644 --- a/spec/models/budget/investment_spec.rb +++ b/spec/models/budget/investment_spec.rb @@ -236,6 +236,18 @@ describe Budget::Investment do budget.phase = "selecting" expect(district_sp.reason_for_not_being_selectable_by(user)).to be_nil end + + it "rejects votes in two headings of the same group" do + carabanchel = create(:budget_heading, group: group) + salamanca = create(:budget_heading, group: group) + + carabanchel_investment = create(:budget_investment, heading: carabanchel) + salamanca_investment = create(:budget_investment, heading: salamanca) + + create(:vote, votable: carabanchel_investment, voter: user) + + expect(salamanca_investment.valid_heading?(user)).to eq(false) + end end end From 17946b292bc00e9461394726886bb4001a522427 Mon Sep 17 00:00:00 2001 From: rgarcia Date: Fri, 13 Jan 2017 16:37:39 +0100 Subject: [PATCH 10/26] fixes specs --- .../management/budgets/investments_controller.rb | 4 ++++ spec/features/budgets/investments_spec.rb | 6 +++--- spec/features/budgets/votes_spec.rb | 2 +- spec/features/management/budget_investments_spec.rb | 2 +- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/app/controllers/management/budgets/investments_controller.rb b/app/controllers/management/budgets/investments_controller.rb index e790312d6..025b6301d 100644 --- a/app/controllers/management/budgets/investments_controller.rb +++ b/app/controllers/management/budgets/investments_controller.rb @@ -34,6 +34,10 @@ class Management::Budgets::InvestmentsController < Management::BaseController def vote @investment.register_selection(managed_user) load_investment_votes(@investment) + respond_to do |format| + format.html { redirect_to management_budget_investments_path(heading_id: @investment.heading.id) } + format.js + end end def print diff --git a/spec/features/budgets/investments_spec.rb b/spec/features/budgets/investments_spec.rb index 9f3a0cc66..41297230d 100644 --- a/spec/features/budgets/investments_spec.rb +++ b/spec/features/budgets/investments_spec.rb @@ -296,7 +296,7 @@ feature 'Budget Investments' do context "Popup alert to vote only in one heading per group" do - scenario "When supporting in the first heading group", :js, :focus do + scenario "When supporting in the first heading group", :js do carabanchel = create(:budget_heading, group: group) salamanca = create(:budget_heading, group: group) @@ -310,7 +310,7 @@ feature 'Budget Investments' do end end - scenario "When already supported in the group", :js, :focus do + scenario "When already supported in the group", :js do carabanchel = create(:budget_heading, group: group) salamanca = create(:budget_heading, group: group) @@ -327,7 +327,7 @@ feature 'Budget Investments' do end end - scenario "When supporting in another group", :js, :focus do + scenario "When supporting in another group", :js do carabanchel = create(:budget_heading, group: group) another_heading = create(:budget_heading, group: create(:budget_group, budget: budget)) diff --git a/spec/features/budgets/votes_spec.rb b/spec/features/budgets/votes_spec.rb index c31545428..882e98b45 100644 --- a/spec/features/budgets/votes_spec.rb +++ b/spec/features/budgets/votes_spec.rb @@ -55,7 +55,7 @@ feature 'Votes' do feature 'Single spending proposal' do background do - @investment = create(:budget_investment, budget: budget) + @investment = create(:budget_investment, budget: budget, heading: heading) end scenario 'Show no votes' do diff --git a/spec/features/management/budget_investments_spec.rb b/spec/features/management/budget_investments_spec.rb index 02f4cf36f..5b3961306 100644 --- a/spec/features/management/budget_investments_spec.rb +++ b/spec/features/management/budget_investments_spec.rb @@ -140,7 +140,7 @@ feature 'Budget Investments' do context "Supporting" do scenario 'Supporting budget investments on behalf of someone in index view', :js do - budget_investment = create(:budget_investment, budget: @budget) + budget_investment = create(:budget_investment, budget: @budget, heading: @heading) user = create(:user, :level_two) login_managed_user(user) From 6d71cd985c63a1a67c997b73ae9f6e13e75c26af Mon Sep 17 00:00:00 2001 From: rgarcia Date: Fri, 13 Jan 2017 21:15:08 +0100 Subject: [PATCH 11/26] displays appropriate vote info depending on phase --- app/models/budget/investment.rb | 8 ++- .../budgets/investments/_investment.html.erb | 14 ++++-- .../investments/_investment_show.html.erb | 26 +++++++--- config/locales/budgets.en.yml | 2 + config/locales/budgets.es.yml | 2 + config/locales/en.yml | 7 +++ config/locales/es.yml | 7 +++ spec/features/budgets/investments_spec.rb | 49 +++++++++++++++++++ 8 files changed, 103 insertions(+), 12 deletions(-) diff --git a/app/models/budget/investment.rb b/app/models/budget/investment.rb index 4021d2fd2..395b6890e 100644 --- a/app/models/budget/investment.rb +++ b/app/models/budget/investment.rb @@ -214,13 +214,19 @@ class Budget end def should_show_aside? - (budget.selecting? && !unfeasible?) || (budget.balloting? && feasible?) || budget.on_hold? + (budget.selecting? && !unfeasible?) || + (budget.balloting? && feasible?) || + (budget.valuating? && feasible?) end def should_show_votes? budget.selecting? end + def should_show_vote_count? + budget.valuating? + end + def should_show_ballots? budget.balloting? end diff --git a/app/views/budgets/investments/_investment.html.erb b/app/views/budgets/investments/_investment.html.erb index c9c247784..c9391cbe5 100644 --- a/app/views/budgets/investments/_investment.html.erb +++ b/app/views/budgets/investments/_investment.html.erb @@ -46,7 +46,6 @@ <% unless investment.unfeasible? %> <% if investment.should_show_votes? %> -
<%= render partial: '/budgets/investments/votes', locals: { @@ -55,9 +54,17 @@ vote_url: namespaced_budget_investment_vote_path(investment, value: 'yes') } %>
- + <% elsif investment.should_show_vote_count? %> +
+
+ + <%= t("budgets.investments.investment.supports", + count: investment.total_votes) %> + +
+
<% elsif investment.should_show_ballots? %> -
<%= render partial: '/budgets/investments/ballot', locals: { @@ -66,7 +73,6 @@ ballot: ballot } %>
- <% end %> <% end %> diff --git a/app/views/budgets/investments/_investment_show.html.erb b/app/views/budgets/investments/_investment_show.html.erb index 12f23fe87..af3c6b194 100644 --- a/app/views/budgets/investments/_investment_show.html.erb +++ b/app/views/budgets/investments/_investment_show.html.erb @@ -55,11 +55,10 @@ <% if investment.should_show_aside? %>