Allow voting in multiple headings

Now that we have the option of voting in multiple headings per group,
the method of voting in a “different heading assigned” has become
deprecated and thus removed
This commit is contained in:
rgarcia
2018-03-21 19:43:40 +01:00
parent 730072e91e
commit bdffb9765e
8 changed files with 126 additions and 7 deletions

View File

@@ -231,12 +231,12 @@ class Budget
end
def valid_heading?(user)
!different_heading_assigned?(user)
voted_in?([heading.id], user) ||
can_vote_in_another_heading?(user)
end
def different_heading_assigned?(user)
other_heading_ids = group.heading_ids - [heading.id]
voted_in?(other_heading_ids, user)
def can_vote_in_another_heading?(user)
headings_voted_by_user(user).count < group.max_votable_headings
end
def voted_in?(heading_ids, user)

View File

@@ -19,7 +19,7 @@
title: t('budgets.investments.investment.support_title'),
method: "post",
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')} ),
data: (current_user && current_user.voted_in_group?(investment.group) ? nil : { confirm: t('budgets.investments.investment.confirm_group', count: investment.group.max_votable_headings)} ),
"aria-hidden" => css_for_aria_hidden(reason) do %>
<%= t("budgets.investments.investment.give_support") %>
<% end %>
@@ -31,6 +31,7 @@
<p>
<small>
<%= t("votes.budget_investments.#{reason}",
count: investment.group.max_votable_headings,
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)