Class: Decidim::Proposals::VoteProposalType
- Inherits:
-
Api::Types::BaseMutation
- Object
- Api::Types::BaseMutation
- Decidim::Proposals::VoteProposalType
- Defined in:
- lib/decidim/api/mutations/vote_proposal_type.rb
Instance Method Summary collapse
Instance Method Details
#authorized? ⇒ Boolean
23 24 25 26 27 |
# File 'lib/decidim/api/mutations/vote_proposal_type.rb', line 23 def raise Decidim::Api::Errors::MutationNotAuthorizedError, I18n.t("decidim.api.errors.unauthorized_mutation") unless super && allowed_to?(:vote, :proposal, object, context) true end |
#resolve ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/decidim/api/mutations/vote_proposal_type.rb', line 11 def resolve VoteProposal.call(object, current_user) do on(:ok) do return object.reload end on(:invalid) do raise Decidim::Api::Errors::ValidationError, I18n.t("proposal_votes.create.error", scope: "decidim.proposals") end end end |