Allow users to remove their support on investments

Note we don't cast negative votes when users remove their support. That
way we provide compatibility for institutions who have implemented real
negative votes (in case there are / will be any), and we also keep the
database meaningful: it's not that users downvoted something; they
simply removed their upvote.

Co-Authored-By: Javi Martín <javim@elretirao.net>
Co-Authored-By: Julian Nicolas Herrero <microweb10@gmail.com>
This commit is contained in:
decabeza
2020-06-25 17:58:52 +02:00
committed by Javi Martín
parent 368023986a
commit a851048d56
17 changed files with 209 additions and 22 deletions

View File

@@ -1,6 +1,7 @@
class Management::Budgets::Investments::VotesController < Management::BaseController
load_resource :budget, find_by: :slug_or_id
load_resource :investment, through: :budget, class: "Budget::Investment"
load_and_authorize_resource through: :investment, through_association: :votes_for, only: :destroy
def create
@investment.register_selection(managed_user)
@@ -11,7 +12,15 @@ class Management::Budgets::Investments::VotesController < Management::BaseContro
notice: t("flash.actions.create.support")
end
format.js
format.js { render :show }
end
end
def destroy
@investment.unliked_by(managed_user)
respond_to do |format|
format.js { render :show }
end
end
end