Class: Decidim::Verifications::IdDocuments::Admin::ConfigController

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

Overview

Handles the configuration for the ID documents verification

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

#editObject


13
14
15
16
17
# File 'decidim-verifications/app/controllers/decidim/verifications/id_documents/admin/config_controller.rb', line 13

def edit
  enforce_permission_to :update, :organization, organization: current_organization

  @form = form(ConfigForm).from_model(current_organization)
end

#updateObject


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

def update
  enforce_permission_to :update, :organization, organization: current_organization

  @form = form(ConfigForm).from_params(params)

  UpdateConfig.call(@form) do
    on(:ok) do
      flash[:notice] = t("config.update.success", scope: "decidim.verifications.id_documents.admin")
      redirect_to pending_authorizations_path
    end

    on(:invalid) do
      flash.now[:alert] = t("config.update.error", scope: "decidim.verifications.id_documents.admin")
      render action: :edit
    end
  end
end