Class: DummySignatureHandler
- Inherits:
-
Decidim::Initiatives::SignatureHandler
- Object
- Decidim::Initiatives::SignatureHandler
- DummySignatureHandler
- Defined in:
- lib/decidim/generators/app_templates/dummy_signature_handler.rb
Overview
An example signature handler used so that users can be verified against third party systems.
You should probably rename this class and file to match your needs.
If you need a custom form to be rendered, you can create a file matching the class name named “_form”.
Example:
A handler named Decidim::CensusSignatureHandler would look for its partial in:
decidim/initiatives/initiative_signatures/census_signature/form
See Decidim::Initiatives::SignatureHandler for more documentation.
Defined Under Namespace
Classes: DummySignatureActionAuthorizer
Constant Summary collapse
- AVAILABLE_GENDERS =
i18n-tasks-use t(“decidim.initiatives.initiative_signatures.dummy_signature.form.fields.gender.options.man”) i18n-tasks-use t(“decidim.initiatives.initiative_signatures.dummy_signature.form.fields.gender.options.non_binary”) i18n-tasks-use t(“decidim.initiatives.initiative_signatures.dummy_signature.form.fields.gender.options.woman”)
%w(man woman non_binary).freeze
Instance Method Summary collapse
-
#authorization_handler_params ⇒ Object
Params to be passed to the authorization handler if defined in the workflow.
- #date_of_birth=(date) ⇒ Object
- #document_types_for_select ⇒ Object
- #genders_for_select ⇒ Object
-
#metadata ⇒ Object
Any data that the developer would like to inject to the ‘metadata` field of a vote when it is created.
-
#scope ⇒ Object
The user scope.
-
#unique_id ⇒ Object
If set, enforces the handler to validate the uniqueness of the field.
Instance Method Details
#authorization_handler_params ⇒ Object
Params to be passed to the authorization handler if defined in the workflow.
109 110 111 |
# File 'lib/decidim/generators/app_templates/dummy_signature_handler.rb', line 109 def super.merge(scope_id:) end |
#date_of_birth=(date) ⇒ Object
50 51 52 53 54 |
# File 'lib/decidim/generators/app_templates/dummy_signature_handler.rb', line 50 def date_of_birth=(date) date = nil if date.is_a?(Hash) && date.values.any?(&:blank?) super end |
#document_types_for_select ⇒ Object
56 57 58 59 60 61 62 63 |
# File 'lib/decidim/generators/app_templates/dummy_signature_handler.rb', line 56 def document_types_for_select document_types.map do |type| [ I18n.t(type.downcase, scope: "decidim.verifications.id_documents"), type ] end end |
#genders_for_select ⇒ Object
65 66 67 68 69 70 71 72 |
# File 'lib/decidim/generators/app_templates/dummy_signature_handler.rb', line 65 def genders_for_select available_genders.map do |gender| [ I18n.t(gender, scope: "decidim.initiatives.initiative_signatures.dummy_signature.form.fields.gender.options", default: gender.humanize), gender ] end end |
#metadata ⇒ Object
Any data that the developer would like to inject to the ‘metadata` field of a vote when it is created. Can be useful if some of the params the user sent with the signature form want to be persisted for future use.
Returns a Hash.
104 105 106 |
# File 'lib/decidim/generators/app_templates/dummy_signature_handler.rb', line 104 def super.merge(name_and_surname:, document_type:, document_number:, gender:, date_of_birth:, postal_code:) end |
#scope ⇒ Object
The user scope
95 96 97 |
# File 'lib/decidim/generators/app_templates/dummy_signature_handler.rb', line 95 def scope user.organization.scopes.find_by(id: scope_id) if scope_id end |
#unique_id ⇒ Object
If set, enforces the handler to validate the uniqueness of the field
89 90 91 |
# File 'lib/decidim/generators/app_templates/dummy_signature_handler.rb', line 89 def unique_id document_number end |