Class: Decidim::System::BaseOrganizationForm
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|
Decidim.omniauth_providers[provider].keys.map do |setting|
if setting == :enabled
[:"omniauth_settings_#{provider}_enabled", Boolean]
else
[:"omniauth_settings_#{provider}_#{setting}", String]
end
end
end.flatten(1)
AttributeObject::TypeMap::Boolean, AttributeObject::TypeMap::Decimal
Instance Attribute Summary
#context
Instance Method Summary
collapse
#attachment?, #default_locale?
ensure_hash, from_model, from_params, hash_from, infer_model_name, mimic, mimicked_model_name, model_name, #persisted?, #to_key, #to_model, #to_param, #valid?, #with_context
#[], #[]=, #attributes, #attributes_with_values, #initialize, #to_h
Instance Method Details
#clean_available_authorizations ⇒ Object
81
82
83
84
85
|
# File 'decidim-system/app/forms/decidim/system/base_organization_form.rb', line 81
def clean_available_authorizations
return unless available_authorizations
available_authorizations.compact_blank
end
|
#clean_secondary_hosts ⇒ Object
75
76
77
78
79
|
# File 'decidim-system/app/forms/decidim/system/base_organization_form.rb', line 75
def clean_secondary_hosts
return unless secondary_hosts
secondary_hosts.split("\n").map(&:chomp).compact_blank
end
|
#encrypted_omniauth_settings ⇒ Object
105
106
107
108
109
110
111
|
# File 'decidim-system/app/forms/decidim/system/base_organization_form.rb', line 105
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
91
92
93
94
95
96
97
|
# File 'decidim-system/app/forms/decidim/system/base_organization_form.rb', line 91
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
#password ⇒ Object
87
88
89
|
# File 'decidim-system/app/forms/decidim/system/base_organization_form.rb', line 87
def password
encrypted_password.nil? ? super : Decidim::AttributeEncryptor.decrypt(encrypted_password)
end
|
#set_from ⇒ Object
99
100
101
102
103
|
# File 'decidim-system/app/forms/decidim/system/base_organization_form.rb', line 99
def set_from
return from_email if from_label.blank?
"#{from_label} <#{from_email}>"
end
|