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

Inherits:
Admin::ApplicationController show all
Defined in:
decidim-verifications/app/controllers/decidim/verifications/postal_letter/admin/postages_controller.rb

Overview

Handles postages for verification letters.

Instance Method Summary collapse

Methods inherited from Admin::ApplicationController

#permission_class_chain, #permission_scope, #user_has_no_permission_path, #user_not_authorized_path

Methods included from HttpCachingDisabler

#disable_http_caching

Methods included from NeedsSnippets

#snippets

Methods included from RegistersPermissions

register_permissions

Methods included from NeedsOrganization

enhance_controller, extended, included

Instance Method Details

#createObject


15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'decidim-verifications/app/controllers/decidim/verifications/postal_letter/admin/postages_controller.rb', line 15

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