Class: Decidim::Elections::Admin::Censuses::InternalUsersForm

Inherits:
Form
  • Object
show all
Defined in:
app/forms/decidim/elections/admin/censuses/internal_users_form.rb

Instance Method Summary collapse

Instance Method Details

#authorization_handler_options(handler_name) ⇒ Object



38
39
40
# File 'app/forms/decidim/elections/admin/censuses/internal_users_form.rb', line 38

def authorization_handler_options(handler_name)
  authorization_handlers_options&.dig(handler_name.to_s) || authorization_handlers&.dig(handler_name, "options").presence || {}
end

#authorization_handlers_namesObject



34
35
36
# File 'app/forms/decidim/elections/admin/censuses/internal_users_form.rb', line 34

def authorization_handlers_names
  super.presence || authorization_handlers.keys.map(&:to_s)
end

#available_authorizationsObject

Helper for the view, at this point, ephemeral authorizations are not supported in the elections module.



56
57
58
59
60
# File 'app/forms/decidim/elections/admin/censuses/internal_users_form.rb', line 56

def available_authorizations
  Decidim.authorization_workflows.filter do |workflow|
    organization_available_authorizations.include?(workflow.name) && !workflow.ephemeral?
  end
end

#census_settingsObject

Returns the settings that need to be persisted in the census.



17
18
19
20
21
# File 'app/forms/decidim/elections/admin/censuses/internal_users_form.rb', line 17

def census_settings
  {
    authorization_handlers: parsed_authorization_handlers
  }
end

#manifest(handler_name) ⇒ Object



42
43
44
# File 'app/forms/decidim/elections/admin/censuses/internal_users_form.rb', line 42

def manifest(handler_name)
  Decidim::Verifications.find_workflow_manifest(handler_name)
end

#options_attributes(handler_name) ⇒ Object



50
51
52
53
# File 'app/forms/decidim/elections/admin/censuses/internal_users_form.rb', line 50

def options_attributes(handler_name)
  manifest = options_manifest(handler_name)
  manifest ? manifest.attributes : []
end

#options_schema(handler_name) ⇒ Object



46
47
48
# File 'app/forms/decidim/elections/admin/censuses/internal_users_form.rb', line 46

def options_schema(handler_name)
  options_manifest(handler_name).schema.new(authorization_handler_options(handler_name))
end

#parsed_authorization_handlersObject



23
24
25
26
27
28
29
30
31
32
# File 'app/forms/decidim/elections/admin/censuses/internal_users_form.rb', line 23

def parsed_authorization_handlers
  authorization_handlers_names.filter_map do |name|
    next if name.blank?

    [
      name,
      { options: authorization_handler_options(name) }
    ]
  end.to_h
end