From 0e581896c0041e83965194d0182dfc9ee037051a Mon Sep 17 00:00:00 2001
From: decabeza
Date: Fri, 26 May 2017 17:12:21 +0200
Subject: [PATCH] improves message when not enough money
---
app/models/budget/investment.rb | 2 +-
app/views/budgets/investments/_ballot.html.erb | 5 +++--
config/locales/budgets.en.yml | 3 ++-
config/locales/budgets.es.yml | 3 ++-
spec/models/budget/investment_spec.rb | 2 +-
5 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/app/models/budget/investment.rb b/app/models/budget/investment.rb
index 56a50deec..7aabf7093 100644
--- a/app/models/budget/investment.rb
+++ b/app/models/budget/investment.rb
@@ -145,7 +145,7 @@ class Budget
return :not_selected unless selected?
return :no_ballots_allowed unless budget.balloting?
return :different_heading_assigned unless ballot.valid_heading?(heading)
- return :not_enough_money if ballot.present? && !enough_money?(ballot)
+ return :not_enough_money_html if ballot.present? && !enough_money?(ballot)
end
def permission_problem(user)
diff --git a/app/views/budgets/investments/_ballot.html.erb b/app/views/budgets/investments/_ballot.html.erb
index 0ad43ab43..605caebc7 100644
--- a/app/views/budgets/investments/_ballot.html.erb
+++ b/app/views/budgets/investments/_ballot.html.erb
@@ -50,8 +50,9 @@
signup: link_to(t("votes.signup"), new_user_registration_path),
my_heading: link_to(investment.heading.name,
budget_investments_path(budget_id: investment.budget_id,
- heading_id: investment.heading_id))
- ).html_safe %>
+ heading_id: investment.heading_id)),
+ change_ballot: link_to(t("budgets.ballots.reasons_for_not_balloting.change_ballot"),
+ budget_ballot_path(@budget))).html_safe %>
diff --git a/config/locales/budgets.en.yml b/config/locales/budgets.en.yml
index 19b52e976..6fba08534 100644
--- a/config/locales/budgets.en.yml
+++ b/config/locales/budgets.en.yml
@@ -17,9 +17,10 @@ en:
not_verified: Only verified users can vote on investments; %{verify_account}.
organization: Organizations are not permitted to vote
not_selected: Unselected investment projects can not be supported
- not_enough_money: "Price is higher than the available amount left."
+ not_enough_money_html: "You have already assigned the available budget.
Remember you can %{change_ballot} at any time"
no_ballots_allowed: Selecting phase is closed
different_heading_assigned: You have already voted a different heading
+ change_ballot: change your votes
groups:
show:
title: Select an option
diff --git a/config/locales/budgets.es.yml b/config/locales/budgets.es.yml
index 6475eea79..1cb308472 100644
--- a/config/locales/budgets.es.yml
+++ b/config/locales/budgets.es.yml
@@ -17,9 +17,10 @@ es:
not_verified: Las propuestas de inversión sólo pueden ser apoyadas por usuarios verificados, %{verify_account}.
organization: Las organizaciones no pueden votar.
not_selected: No se pueden votar propuestas inviables.
- not_enough_money: No hay fondos suficientes.
+ not_enough_money_html: "Ya has asignado el presupuesto disponible.
Recuerda que puedes %{change_ballot} en cualquier momento"
no_ballots_allowed: El periodo de votación está cerrado.
different_heading_assigned: Ya votaste en una sección distinta del presupuesto.
+ change_ballot: cambiar tus votos
groups:
show:
title: Selecciona una opción
diff --git a/spec/models/budget/investment_spec.rb b/spec/models/budget/investment_spec.rb
index b811e8061..2290abba9 100644
--- a/spec/models/budget/investment_spec.rb
+++ b/spec/models/budget/investment_spec.rb
@@ -712,7 +712,7 @@ describe Budget::Investment do
ballot = create(:budget_ballot, user: user, budget: budget)
ballot.investments << inv1
- expect(inv2.reason_for_not_being_ballotable_by(user, ballot)).to eq(:not_enough_money)
+ expect(inv2.reason_for_not_being_ballotable_by(user, ballot)).to eq(:not_enough_money_html)
end
end