Module: Decidim::VerifyWoRegistration::ApplicationHelper

Included in:
VerificationsController
Defined in:
app/helpers/decidim/verify_wo_registration/application_helper.rb

Overview

Custom helpers, scoped to the verify_wo_registration engine.

Class Method Summary collapse

Class Method Details

.all_verifications_of_type_direct?(component) ⇒ Boolean

Checks whether all workflow manifests for the givevn component are of type “direct”.

Returns:

  • (Boolean)


23
24
25
26
# File 'app/helpers/decidim/verify_wo_registration/application_helper.rb', line 23

def self.all_verifications_of_type_direct?(component)
  manifests = workflow_manifests(component)
  manifests.any? && manifests.all? { |manifest| manifest.type == 'direct' }
end

.verify_wo_registration_custom_modal?(component) ⇒ Boolean

Returns:

  • (Boolean)


8
9
10
# File 'app/helpers/decidim/verify_wo_registration/application_helper.rb', line 8

def self.verify_wo_registration_custom_modal?(component)
  component.settings.try(:supports_without_registration) && all_verifications_of_type_direct?(component)
end

.workflow_manifests(component) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'app/helpers/decidim/verify_wo_registration/application_helper.rb', line 12

def self.workflow_manifests(component)
  return [] if component.permissions&.blank? || component.permissions.try(:fetch, "vote").blank?

  Decidim::Verifications::Adapter.from_collection(
    # component.permissions returns a structure of the form:
    # {"vote"=>{"authorization_handlers"=>{"dummy_authorization_handler"=>{"options"=>{"postal_code"=>"08001"}}}}}
    component.permissions['vote']['authorization_handlers'].keys
  )
end