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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user