diff --git a/app/assets/stylesheets/layout.scss b/app/assets/stylesheets/layout.scss index 7c3300fa3..1511910b1 100644 --- a/app/assets/stylesheets/layout.scss +++ b/app/assets/stylesheets/layout.scss @@ -70,6 +70,11 @@ a { } } +.button.hollow { + border: 1px solid $link; + color: $link; +} + .postfix.button { padding: 0; } diff --git a/app/controllers/budgets/investments_controller.rb b/app/controllers/budgets/investments_controller.rb index 0a5e78eef..7f9c6e7ee 100644 --- a/app/controllers/budgets/investments_controller.rb +++ b/app/controllers/budgets/investments_controller.rb @@ -55,7 +55,7 @@ module Budgets end def destroy - investment.destroy + @investment.destroy redirect_to user_path(current_user, filter: 'budget_investments'), notice: t('flash.actions.destroy.budget_investment') end diff --git a/app/helpers/budgets_helper.rb b/app/helpers/budgets_helper.rb index 84f04139c..4b9dfd311 100644 --- a/app/helpers/budgets_helper.rb +++ b/app/helpers/budgets_helper.rb @@ -38,4 +38,8 @@ module BudgetsHelper def current_ballot Budget::Ballot.where(user: current_user, budget: @budget).first end + + def investment_tags_select_options + Budget::Investment.tags_on(:valuation).order(:name).select(:name).distinct + end end diff --git a/app/models/abilities/common.rb b/app/models/abilities/common.rb index e324540d2..7ac6a12f4 100644 --- a/app/models/abilities/common.rb +++ b/app/models/abilities/common.rb @@ -46,6 +46,7 @@ module Abilities can :create, SpendingProposal can :create, Budget::Investment, budget: { phase: "accepting" } + can :destroy, Budget::Investment, budget: { phase: ["accepting", "reviewing"] }, author_id: user.id can :vote, Budget::Investment, budget: { phase: "selecting" } can [:show, :create], Budget::Ballot, budget: { phase: "balloting" } can [:create, :destroy], Budget::Ballot::Line, budget: { phase: "balloting" } diff --git a/app/views/admin/budget_investments/index.html.erb b/app/views/admin/budget_investments/index.html.erb index 126a933b7..beb5eb856 100644 --- a/app/views/admin/budget_investments/index.html.erb +++ b/app/views/admin/budget_investments/index.html.erb @@ -28,7 +28,7 @@
<%= select_tag :tag_name, - options_for_select(spending_proposal_tags_select_options, params[:tag_name]), + options_for_select(investment_tags_select_options, params[:tag_name]), { prompt: t("admin.budget_investments.index.tags_filter_all"), label: false, class: "js-submit-on-change" } %> diff --git a/app/views/admin/budgets/_group.html.erb b/app/views/admin/budgets/_group.html.erb index 422834f61..e90bd4905 100644 --- a/app/views/admin/budgets/_group.html.erb +++ b/app/views/admin/budgets/_group.html.erb @@ -7,23 +7,24 @@ - <% if headings.blank? %> - - - -
- <%= t("admin.budgets.form.no_heading") %> -
- - - <% else %> - - <%= t("admin.budgets.form.table_heading") %> - <%= t("admin.budgets.form.table_amount") %> - - - - <% end %> + <% if headings.blank? %> + + + + +
+ <%= t("admin.budgets.form.no_heading") %> +
+ + + <% else %> + + <%= t("admin.budgets.form.table_heading") %> + <%= t("admin.budgets.form.table_amount") %> + + + + <% end %> @@ -52,16 +53,15 @@ <% headings.each do |heading| %> - - - <%= heading.name %> - - - <%= heading.price %> - - + + + <%= heading.name %> + + + <%= heading.price %> + + <% end %> - - -
+ + diff --git a/app/views/budgets/investments/_investment_show.html.erb b/app/views/budgets/investments/_investment_show.html.erb index 17abf4faf..ebac39186 100644 --- a/app/views/budgets/investments/_investment_show.html.erb +++ b/app/views/budgets/investments/_investment_show.html.erb @@ -105,6 +105,7 @@ <% if browser.device.mobile? %> + <%= t("social.whatsapp") %> <% end %> diff --git a/app/views/debates/show.html.erb b/app/views/debates/show.html.erb index 363a3bab3..096369bc3 100644 --- a/app/views/debates/show.html.erb +++ b/app/views/debates/show.html.erb @@ -55,6 +55,7 @@ <% if browser.device.mobile? %> + <%= t("social.whatsapp") %> <% end %> diff --git a/app/views/proposals/_filter_subnav.html.erb b/app/views/proposals/_filter_subnav.html.erb index fe875c9a9..6347d56b0 100644 --- a/app/views/proposals/_filter_subnav.html.erb +++ b/app/views/proposals/_filter_subnav.html.erb @@ -1,6 +1,6 @@
-
@@ -136,7 +137,7 @@
<% end %> -
+
<%= render "proposals/filter_subnav" %> <%= render "proposals/notifications" %> diff --git a/app/views/spending_proposals/show.html.erb b/app/views/spending_proposals/show.html.erb index 0da045860..4cdfb688b 100644 --- a/app/views/spending_proposals/show.html.erb +++ b/app/views/spending_proposals/show.html.erb @@ -47,6 +47,7 @@ <% if browser.device.mobile? %> + <%= t("social.whatsapp") %> <% end %>
diff --git a/app/views/users/_budget_investments.html.erb b/app/views/users/_budget_investments.html.erb index b5773cbdf..64cad676d 100644 --- a/app/views/users/_budget_investments.html.erb +++ b/app/views/users/_budget_investments.html.erb @@ -4,6 +4,12 @@ <%= link_to budget_investment.title, budget_investment_path(budget_investment.budget, budget_investment) %> + + <% if can? :destroy, budget_investment %> + <%= link_to t('shared.delete'), budget_investment_path(budget_investment.budget, budget_investment), + method: :delete, class: "button hollow alert" %> + <% end %> + <% end %> diff --git a/config/locales/en.yml b/config/locales/en.yml index 9cc3c4027..1c854bb7e 100755 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -200,7 +200,7 @@ en: external_link_transparency: Transparency external_link_transparency_url: https://transparency.consul locale: 'Language:' - logo: Consul + logo: Consul logo management: Management moderation: Moderation valuation: Valuation @@ -435,6 +435,7 @@ en: search: 'Filter' title: 'Advanced search' to: 'To' + delete: Delete author_info: author_deleted: User deleted back: Go back @@ -479,6 +480,7 @@ en: facebook: Facebook twitter: Twitter youtube: YouTube + whatsapp: WhatsApp spending_proposals: form: association_name_label: 'If you propose in name of an assocation or collective add the name here' diff --git a/config/locales/es.yml b/config/locales/es.yml index 4c0484b97..0438cb9e3 100755 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -200,7 +200,7 @@ es: external_link_transparency: Transparencia external_link_transparency_url: https://transparency.consul locale: 'Idioma:' - logo: Consul + logo: Consul logo management: Gestión moderation: Moderar valuation: Evaluación @@ -435,6 +435,7 @@ es: search: 'Filtrar' title: 'Búsqueda avanzada' to: 'Hasta' + delete: 'Borrar' author_info: author_deleted: Usuario eliminado back: Volver @@ -479,6 +480,7 @@ es: facebook: Facebook twitter: Twitter youtube: YouTube + whatsapp: WhatsApp spending_proposals: form: association_name_label: 'Si propones en nombre de una asociación o colectivo añade el nombre aquí' diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 596531c0d..cc0b1c590 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -874,7 +874,7 @@ fr: external_link_transparency: Transparence external_link_transparency_url: https://transparency.consul locale: 'Langue :' - logo: Consul + logo: Consul logo moderation: Modération more_information: Plus d'information my_account_link: Mon compte diff --git a/config/locales/pt-BR.yml b/config/locales/pt-BR.yml index 75e7aebb6..febe0ed5c 100644 --- a/config/locales/pt-BR.yml +++ b/config/locales/pt-BR.yml @@ -860,7 +860,7 @@ pt-BR: external_link_transparency: Transparência external_link_transparency_url: https://transparency.consul locale: 'Idioma:' - logo: Consul + logo: Consul logotipo moderation: Moderação more_information: Mais informações my_account_link: Minha conta diff --git a/config/locales/social_share_button.en.yml b/config/locales/social_share_button.en.yml index b06cb5ad3..84ee6baba 100644 --- a/config/locales/social_share_button.en.yml +++ b/config/locales/social_share_button.en.yml @@ -16,4 +16,4 @@ en: tumblr: "Tumblr" plurk: "Plurk" pinterest: "Pinterest" - email: "Email" + email: "Email" \ No newline at end of file diff --git a/config/locales/social_share_button.es.yml b/config/locales/social_share_button.es.yml index 45e4ab2a5..aa0c3f224 100644 --- a/config/locales/social_share_button.es.yml +++ b/config/locales/social_share_button.es.yml @@ -16,4 +16,4 @@ es: tumblr: "Tumblr" plurk: "Plurk" pinterest: "Pinterest" - email: "Correo electrónico" + email: "Correo electrónico" \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index c2639389f..fbd599f89 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -331,7 +331,7 @@ Rails.application.routes.draw do get :support_investments get :print_investments end - resources :investments, only: [:index, :new, :create, :show], controller: 'budgets/investments' do + resources :investments, only: [:index, :new, :create, :show, :destroy], controller: 'budgets/investments' do post :vote, on: :member get :print, on: :collection end diff --git a/public/404.html b/public/404.html index cc6820bba..5b5362192 100644 --- a/public/404.html +++ b/public/404.html @@ -1,5 +1,5 @@ - + Error 404 | Not found diff --git a/public/422.html b/public/422.html index e68d2956f..cca90e5a3 100644 --- a/public/422.html +++ b/public/422.html @@ -1,5 +1,5 @@ - + Error 422 | The change you wanted was rejected diff --git a/public/500.html b/public/500.html index 71978cdce..0b563452a 100644 --- a/public/500.html +++ b/public/500.html @@ -1,5 +1,5 @@ - + Error 500 | Internal server error diff --git a/spec/features/admin/budget_investments_spec.rb b/spec/features/admin/budget_investments_spec.rb index ede09ec4f..f4dde2425 100644 --- a/spec/features/admin/budget_investments_spec.rb +++ b/spec/features/admin/budget_investments_spec.rb @@ -252,6 +252,21 @@ feature 'Admin budget investments' do expect(page).to have_content("More schools") end + scenario "Filtering by tag, display only valuation tags" do + investment1 = create(:budget_investment, budget: @budget, tag_list: 'Education') + investment2 = create(:budget_investment, budget: @budget, tag_list: 'Health') + + investment1.set_tag_list_on(:valuation, 'Teachers') + investment2.set_tag_list_on(:valuation, 'Hospitals') + + investment1.save + investment2.save + + visit admin_budget_budget_investments_path(budget_id: @budget.id) + + expect(page).to have_select("tag_name", options: ["All tags", "Hospitals", "Teachers"]) + end + end scenario 'Show' do diff --git a/spec/features/budgets/investments_spec.rb b/spec/features/budgets/investments_spec.rb index a6feb6f44..1d812bd7e 100644 --- a/spec/features/budgets/investments_spec.rb +++ b/spec/features/budgets/investments_spec.rb @@ -315,6 +315,20 @@ feature 'Budget Investments' do end end + scenario "Author can destroy while on the accepting phase" do + user = create(:user, :level_two) + sp1 = create(:budget_investment, heading: heading, price: 10000, author: user) + + login_as(user) + visit user_path(user, tab: :budget_investments) + + within("#budget_investment_#{sp1.id}") do + expect(page).to have_content(sp1.title) + click_link('Delete') + end + + visit user_path(user, tab: :budget_investments) + end end context "Selecting Phase" do @@ -476,6 +490,8 @@ feature 'Budget Investments' do expect(page).to have_content "€10,000" end + + scenario "Sidebar in show should display vote text" do investment = create(:budget_investment, :selected, budget: budget) visit budget_investment_path(budget, investment) @@ -561,4 +577,4 @@ feature 'Budget Investments' do end end -end \ No newline at end of file +end diff --git a/spec/models/abilities/common_spec.rb b/spec/models/abilities/common_spec.rb index ce90ab967..f82bcc839 100644 --- a/spec/models/abilities/common_spec.rb +++ b/spec/models/abilities/common_spec.rb @@ -10,12 +10,18 @@ describe "Abilities::Common" do let(:comment) { create(:comment) } let(:proposal) { create(:proposal) } let(:accepting_budget) { create(:budget, phase: 'accepting') } + let(:reviewing_budget) { create(:budget, phase: 'reviewing') } let(:selecting_budget) { create(:budget, phase: 'selecting') } let(:balloting_budget) { create(:budget, phase: 'balloting') } let(:investment_in_accepting_budget) { create(:budget_investment, budget: accepting_budget) } + let(:investment_in_reviewing_budget) { create(:budget_investment, budget: reviewing_budget) } let(:investment_in_selecting_budget) { create(:budget_investment, budget: selecting_budget) } let(:investment_in_balloting_budget) { create(:budget_investment, budget: balloting_budget) } + let(:own_investment_in_accepting_budget) { create(:budget_investment, budget: accepting_budget, author: user) } + let(:own_investment_in_reviewing_budget) { create(:budget_investment, budget: reviewing_budget, author: user) } + let(:own_investment_in_selecting_budget) { create(:budget_investment, budget: selecting_budget, author: user) } + let(:own_investment_in_balloting_budget) { create(:budget_investment, budget: balloting_budget, author: user) } let(:ballot_in_accepting_budget) { create(:budget_ballot, budget: accepting_budget) } let(:ballot_in_selecting_budget) { create(:budget_ballot, budget: selecting_budget) } let(:ballot_in_balloting_budget) { create(:budget_ballot, budget: balloting_budget) } @@ -117,6 +123,16 @@ describe "Abilities::Common" do it { should be_able_to(:vote, investment_in_selecting_budget) } it { should_not be_able_to(:vote, investment_in_balloting_budget) } + it { should_not be_able_to(:destroy, investment_in_accepting_budget) } + it { should_not be_able_to(:destroy, investment_in_reviewing_budget) } + it { should_not be_able_to(:destroy, investment_in_selecting_budget) } + it { should_not be_able_to(:destroy, investment_in_balloting_budget) } + + it { should be_able_to(:destroy, own_investment_in_accepting_budget) } + it { should be_able_to(:destroy, own_investment_in_reviewing_budget) } + it { should_not be_able_to(:destroy, own_investment_in_selecting_budget) } + it { should_not be_able_to(:destroy, investment_in_balloting_budget) } + it { should_not be_able_to(:create, ballot_in_accepting_budget) } it { should_not be_able_to(:create, ballot_in_selecting_budget) } it { should be_able_to(:create, ballot_in_balloting_budget) }