Class: Decidim::VerifyWoRegistration::VerifyWoRegistrationForm
- Inherits:
-
Form
- Object
- Form
- Decidim::VerifyWoRegistration::VerifyWoRegistrationForm
- Defined in:
- app/forms/decidim/verify_wo_registration/verify_wo_registration_form.rb
Overview
A form object used to wrap and validate params from the controller to the command.
Instance Method Summary collapse
-
#authorization_handlers ⇒ Object
Returns authorization_handlers that were configured for the current component.
- #component ⇒ Object
- #default_handler_params ⇒ Object
-
#handler_params(handler_name) ⇒ Object
The authorizations from the params may be in the following format:.
- #new_verified_user ⇒ Object
-
#verified_handler ⇒ Object
Provides the handler that verified the user data to the command.
Instance Method Details
#authorization_handlers ⇒ Object
Returns authorization_handlers that were configured for the current component
16 17 18 19 20 21 22 |
# File 'app/forms/decidim/verify_wo_registration/verify_wo_registration_form.rb', line 16 def @authorization_handlers ||= begin ::Decidim::VerifyWoRegistration::ApplicationHelper.workflow_manifests(component).map do |workflow_manifest| Decidim::AuthorizationHandler.handler_for(workflow_manifest.name, handler_params(workflow_manifest.name)) end end end |
#component ⇒ Object
57 58 59 60 61 62 63 64 |
# File 'app/forms/decidim/verify_wo_registration/verify_wo_registration_form.rb', line 57 def component @component ||= begin c = Decidim::Component.find(component_id) raise ArgumentError unless c.participatory_space.organization.id == current_organization.id c end end |
#default_handler_params ⇒ Object
40 41 42 |
# File 'app/forms/decidim/verify_wo_registration/verify_wo_registration_form.rb', line 40 def default_handler_params { user: new_verified_user } end |
#handler_params(handler_name) ⇒ Object
The authorizations from the params may be in the following format:
“‘ “document_number”=>“00000000X”, “postal_code”=>“00000”, “birthday”=>“23/06/6”} “`
30 31 32 33 34 35 36 37 38 |
# File 'app/forms/decidim/verify_wo_registration/verify_wo_registration_form.rb', line 30 def handler_params(handler_name) = return default_handler_params if .nil? = .values.find { |h| h.with_indifferent_access[:handler_name] == handler_name } return default_handler_params if .nil? .merge(default_handler_params) end |
#new_verified_user ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'app/forms/decidim/verify_wo_registration/verify_wo_registration_form.rb', line 44 def new_verified_user @new_verified_user ||= Decidim::User.new( organization: current_organization, admin: false, managed: true, name: Time.current.utc.to_s(:number) ) do |u| u.nickname = UserBaseEntity.nicknamize(u.name, organization: current_organization) u.tos_agreement = true u.skip_confirmation! end end |
#verified_handler ⇒ Object
Provides the handler that verified the user data to the command
67 68 69 |
# File 'app/forms/decidim/verify_wo_registration/verify_wo_registration_form.rb', line 67 def verified_handler @verified_handler end |