Merge pull request #2528 from consul/budgets-message

Heading link on budgets message
This commit is contained in:
Alberto García
2018-03-09 13:25:39 +01:00
committed by GitHub
10 changed files with 39 additions and 28 deletions

View File

@@ -6,4 +6,10 @@ module BudgetHeadingsHelper
end
end
def heading_link(assigned_heading = nil, budget = nil)
return nil unless assigned_heading && budget
heading_path = budget_investments_path(budget, heading_id: assigned_heading.try(:id))
link_to(assigned_heading.name, heading_path)
end
end

View File

@@ -208,11 +208,11 @@ class Budget
end
def reason_for_not_being_ballotable_by(user, ballot)
return permission_problem(user) if permission_problem?(user)
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_html if ballot.present? && !enough_money?(ballot)
return permission_problem(user) if permission_problem?(user)
return :not_selected unless selected?
return :no_ballots_allowed unless budget.balloting?
return :different_heading_assigned_html unless ballot.valid_heading?(heading)
return :not_enough_money_html if ballot.present? && !enough_money?(ballot)
end
def permission_problem(user)

View File

@@ -42,17 +42,25 @@
<% if reason.present? && !ballot.has_investment?(investment) %>
<div class="js-participation-not-allowed participation-not-allowed" style='display:none'>
<div class="js-participation-not-allowed participation-not-allowed" style="display:none">
<% verify_account = link_to(t("votes.verify_account"), verification_path) %>
<% signin = link_to(t("votes.signin"), new_user_session_path) %>
<% 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)) %>
<% change_ballot = link_to(t("budgets.ballots.reasons_for_not_balloting.change_ballot"),
budget_ballot_path(@budget))%>
<p>
<%= t("budgets.ballots.reasons_for_not_balloting.#{reason}",
verify_account: link_to(t("votes.verify_account"), verification_path),
signin: link_to(t("votes.signin"), new_user_session_path),
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)),
change_ballot: link_to(t("budgets.ballots.reasons_for_not_balloting.change_ballot"),
budget_ballot_path(@budget))).html_safe %>
<small>
<%= t("budgets.ballots.reasons_for_not_balloting.#{reason}",
verify_account: verify_account, signin: signin,
signup: signup, my_heading: my_heading,
change_ballot: change_ballot,
heading_link: heading_link(@assigned_heading, @budget)).html_safe %>
</small>
</p>
</div>

View File

@@ -35,12 +35,9 @@
<%= t("budgets.investments.index.by_heading", heading: @heading.name) %>
</h2>
<div class="small-12 medium-9">
<div class="callout warning">
<div class="callout warning margin-top">
<%= t("budgets.investments.header.different_heading_assigned_html",
heading_link: link_to(
@assigned_heading.name,
budget_investments_path(@budget, heading_id: @assigned_heading.try(:id)))
) %>
heading_link: heading_link(@assigned_heading, @budget)) %>
<br>
<small>
<%= t("budgets.investments.header.change_ballot",

View File

@@ -43,9 +43,7 @@
<% elsif @assigned_heading.present? %>
<p>
<%= t("budgets.investments.index.sidebar.different_heading_assigned_html",
heading_link: link_to(
@assigned_heading.name,
budget_investments_path(@budget, heading_id: @assigned_heading.try(:id)))
heading_link: heading_link(@assigned_heading, @budget)
) %>
<br>
<small>

View File

@@ -29,11 +29,13 @@
<% if reason.present? && !user_voted_for %>
<div class="js-participation-not-allowed participation-not-allowed" style='display:none' aria-hidden="false">
<p>
<small>
<%= t("votes.budget_investments.#{reason}",
verify_account: link_to(t("votes.verify_account"), verification_path),
signin: link_to(t("votes.signin"), new_user_session_path),
signup: link_to(t("votes.signup"), new_user_registration_path)
).html_safe %>
</small>
</p>
</div>
<% end %>