Class: Decidim::Proposals::ProposalEndorsementsController
- Inherits:
-
ApplicationController
- Object
- Components::BaseController
- ApplicationController
- Decidim::Proposals::ProposalEndorsementsController
- Defined in:
- app/controllers/decidim/proposals/proposal_endorsements_controller.rb
Overview
Exposes the proposal endorsement resource so that users can endorse proposals.
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'app/controllers/decidim/proposals/proposal_endorsements_controller.rb', line 11 def create :endorse, proposal @from_proposals_list = params[:from_proposals_list] == "true" user_group_id = params[:user_group_id] EndorseProposal.call(proposal, current_user, user_group_id) do on(:ok) do proposal.reload render :update_buttons_and_counters end on(:invalid) do render json: { error: I18n.t("proposal_endorsements.create.error", scope: "decidim.proposals") }, status: 422 end end end |
#destroy ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'app/controllers/decidim/proposals/proposal_endorsements_controller.rb', line 28 def destroy :unendorse, proposal @from_proposals_list = params[:from_proposals_list] == "true" user_group_id = params[:user_group_id] user_group = current_user.user_groups.verified.find(user_group_id) if user_group_id UnendorseProposal.call(proposal, current_user, user_group) do on(:ok) do proposal.reload render :update_buttons_and_counters end end end |
#identities ⇒ Object
42 43 44 45 46 47 |
# File 'app/controllers/decidim/proposals/proposal_endorsements_controller.rb', line 42 def identities :endorse, proposal @user_verified_groups = current_user.user_groups.verified render :identities, layout: false end |