Class: Decidim::DirectVerifications::Verification::Admin::ImportsController

Inherits:
Admin::ApplicationController
  • Object
show all
Defined in:
app/controllers/decidim/direct_verifications/verification/admin/imports_controller.rb

Instance Method Summary collapse

Instance Method Details

#configured_workflowsObject



42
43
44
45
46
# File 'app/controllers/decidim/direct_verifications/verification/admin/imports_controller.rb', line 42

def configured_workflows
  return Decidim::DirectVerifications.config.manage_workflows if Decidim::DirectVerifications.config

  ["direct_verifications"]
end

#createObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'app/controllers/decidim/direct_verifications/verification/admin/imports_controller.rb', line 16

def create
  enforce_permission_to :create, :authorization

  defaults = { organization: current_organization, user: current_user }
  form = form(CreateImportForm).from_params(params.merge(defaults))

  CreateImport.call(form) do
    on(:ok) do
      flash[:notice] = t(".success")
    end

    on(:invalid) do
      flash[:alert] = t(".error")
    end
  end

  redirect_to new_import_path
end

#current_authorization_handlerObject



48
49
50
# File 'app/controllers/decidim/direct_verifications/verification/admin/imports_controller.rb', line 48

def current_authorization_handler
  params[:authorization_handler]
end

#newObject



11
12
13
14
# File 'app/controllers/decidim/direct_verifications/verification/admin/imports_controller.rb', line 11

def new
  enforce_permission_to :create, :authorization
  @form = form(CreateImportForm).instance
end

#workflowsObject



35
36
37
38
39
40
# File 'app/controllers/decidim/direct_verifications/verification/admin/imports_controller.rb', line 35

def workflows
  workflows = configured_workflows & current_organization.available_authorizations.map.to_a
  workflows.map do |workflow|
    [t("#{workflow}.name", scope: "decidim.authorization_handlers"), workflow]
  end
end