Class: Decidim::System::BaseOrganizationForm
- Inherits:
-
Form
- Object
- Form
- Decidim::System::BaseOrganizationForm
show all
- Includes:
- JsonbAttributes, TranslatableAttributes
- Defined in:
- app/forms/decidim/system/base_organization_form.rb
Overview
A form object to be inherited to create and update organizations from the system dashboard.
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", Boolean]
else
[:"omniauth_settings_#{provider}_#{setting}", String]
end
end
end.flatten(1)
Instance Method Summary
collapse
Instance Method Details
#clean_available_authorizations ⇒ Object
82
83
84
85
86
|
# File 'app/forms/decidim/system/base_organization_form.rb', line 82
def clean_available_authorizations
return unless available_authorizations
available_authorizations.compact_blank
end
|
#clean_secondary_hosts ⇒ Object
76
77
78
79
80
|
# File 'app/forms/decidim/system/base_organization_form.rb', line 76
def clean_secondary_hosts
return unless secondary_hosts
secondary_hosts.split("\n").map(&:chomp).compact_blank
end
|
#encrypted_omniauth_settings ⇒ Object
106
107
108
109
110
111
112
|
# File 'app/forms/decidim/system/base_organization_form.rb', line 106
def encrypted_omniauth_settings
encrypted = omniauth_settings.transform_values do |v|
Decidim::OmniauthProvider.value_defined?(v) ? Decidim::AttributeEncryptor.encrypt(v) : v
end
encrypted.values.all?(&:blank?) ? nil : encrypted
end
|
#encrypted_smtp_settings ⇒ Object
92
93
94
95
96
97
98
|
# File 'app/forms/decidim/system/base_organization_form.rb', line 92
def encrypted_smtp_settings
smtp_settings["from"] = set_from
encrypted = smtp_settings.merge(encrypted_password: Decidim::AttributeEncryptor.encrypt(password))
encrypted.values.all?(&:blank?) ? nil : encrypted
end
|
#map_model(model) ⇒ Object
67
68
69
70
71
72
73
74
|
# File 'app/forms/decidim/system/base_organization_form.rb', line 67
def map_model(model)
self.default_locale = model.default_locale
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
88
89
90
|
# File 'app/forms/decidim/system/base_organization_form.rb', line 88
def password
encrypted_password.nil? ? super : Decidim::AttributeEncryptor.decrypt(encrypted_password)
end
|
#set_from ⇒ Object
100
101
102
103
104
|
# File 'app/forms/decidim/system/base_organization_form.rb', line 100
def set_from
return from_email if from_label.blank?
"#{from_label} <#{from_email}>"
end
|