Class: Decidim::System::UpdateOrganizationForm
- Inherits:
-
Form
- Object
- Form
- Decidim::System::UpdateOrganizationForm
- Includes:
- JsonbAttributes, TranslatableAttributes
- Defined in:
- app/forms/decidim/system/update_organization_form.rb
Overview
A form object used to update organizations from the system dashboard.
Direct Known Subclasses
Constant Summary collapse
- OMNIATH_PROVIDERS_ATTRIBUTES =
Decidim::OmniauthProvider.available.keys.map do |provider| Rails.application.secrets.dig(:omniauth, provider).keys.map do |setting| if setting == :enabled ["omniauth_settings_#{provider}_enabled".to_sym, Boolean] else ["omniauth_settings_#{provider}_#{setting}".to_sym, String] end end end.flatten(1)
Instance Method Summary collapse
- #clean_available_authorizations ⇒ Object
- #clean_secondary_hosts ⇒ Object
- #encrypted_omniauth_settings ⇒ Object
- #encrypted_smtp_settings ⇒ Object
- #map_model(model) ⇒ Object
- #password ⇒ Object
- #set_from ⇒ Object
Instance Method Details
#clean_available_authorizations ⇒ Object
66 67 68 69 70 |
# File 'app/forms/decidim/system/update_organization_form.rb', line 66 def return unless .select(&:present?) end |
#clean_secondary_hosts ⇒ Object
60 61 62 63 64 |
# File 'app/forms/decidim/system/update_organization_form.rb', line 60 def clean_secondary_hosts return unless secondary_hosts secondary_hosts.split("\n").map(&:chomp).select(&:present?) end |
#encrypted_omniauth_settings ⇒ Object
90 91 92 93 94 95 96 |
# File 'app/forms/decidim/system/update_organization_form.rb', line 90 def encrypted_omniauth_settings encrypted = omniauth_settings.transform_values do |v| Decidim::OmniauthProvider.value_defined?(v) ? Decidim::AttributeEncryptor.encrypt(v) : v end # if all are empty, nil is returned so it does not break ENV vars configuration encrypted.values.all?(&:blank?) ? nil : encrypted end |
#encrypted_smtp_settings ⇒ Object
76 77 78 79 80 81 82 |
# File 'app/forms/decidim/system/update_organization_form.rb', line 76 def encrypted_smtp_settings smtp_settings["from"] = set_from encrypted = smtp_settings.merge(encrypted_password: Decidim::AttributeEncryptor.encrypt(password)) # if all are empty, nil is returned so it does not break ENV vars configuration encrypted.values.all?(&:blank?) ? nil : encrypted end |
#map_model(model) ⇒ Object
52 53 54 55 56 57 58 |
# File 'app/forms/decidim/system/update_organization_form.rb', line 52 def map_model(model) self.secondary_hosts = model.secondary_hosts.join("\n") self.omniauth_settings = (model.omniauth_settings || {}).transform_values do |v| Decidim::OmniauthProvider.value_defined?(v) ? Decidim::AttributeEncryptor.decrypt(v) : v end self.file_upload_settings = FileUploadSettingsForm.from_model(model.file_upload_settings) end |
#password ⇒ Object
72 73 74 |
# File 'app/forms/decidim/system/update_organization_form.rb', line 72 def password encrypted_password.nil? ? super : Decidim::AttributeEncryptor.decrypt(encrypted_password) end |
#set_from ⇒ Object
84 85 86 87 88 |
# File 'app/forms/decidim/system/update_organization_form.rb', line 84 def set_from return from_email if from_label.blank? "#{from_label} <#{from_email}>" end |