Class: Decidim::Verifications::PostalLetter::Admin::PostagesController

Inherits:
Admin::ApplicationController
  • Object
show all
Includes:
Admin::WorkflowsBreadcrumb
Defined in:
app/controllers/decidim/verifications/postal_letter/admin/postages_controller.rb

Overview

Handles postages for verification letters.

Instance Method Summary collapse

Instance Method Details

#createObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'app/controllers/decidim/verifications/postal_letter/admin/postages_controller.rb', line 19

def create
  enforce_permission_to :update, :authorization, authorization: @pending_authorization

  @form = PostageForm.from_model(@pending_authorization)

  PerformAuthorizationStep.call(@pending_authorization, @form) do
    on(:ok) do
      flash[:notice] = t("postages.create.success", scope: "decidim.verifications.postal_letter.admin")
      redirect_to pending_authorizations_path
    end

    on(:invalid) do
      render json: { error: I18n.t("postages.create.error", scope: "decidim.verifications.postal_letter.admin") }, status: :unprocessable_entity
    end
  end
end