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