Class: Decidim::NotificationsSettingsForm
- Inherits:
-
Form
show all
- Defined in:
- decidim-core/app/forms/decidim/notifications_settings_form.rb
Overview
The form object that handles the data behind updating a user’s notifications settings in their profile page.
Constant Summary
AttributeObject::TypeMap::Boolean, AttributeObject::TypeMap::Decimal
Instance Attribute Summary
#context
Instance Method Summary
collapse
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
#direct_message_types ⇒ Object
43
44
45
|
# File 'decidim-core/app/forms/decidim/notifications_settings_form.rb', line 43
def direct_message_types
allow_public_contact ? "all" : "followed-only"
end
|
#map_model(user) ⇒ Object
17
18
19
20
21
22
23
|
# File 'decidim-core/app/forms/decidim/notifications_settings_form.rb', line 17
def map_model(user)
self.newsletter_notifications = user.newsletter_notifications_at.present?
self.notifications_from_followed = ["all", "followed-only"].include? user.notification_types
self.notifications_from_own_activity = ["all", "own-only"].include? user.notification_types
self.allow_public_contact = user.direct_message_types == "all"
self.notifications_sending_frequency = user.notifications_sending_frequency
end
|
#meet_push_notifications_requirements? ⇒ Boolean
47
48
49
|
# File 'decidim-core/app/forms/decidim/notifications_settings_form.rb', line 47
def meet_push_notifications_requirements?
Rails.application.secrets.dig(:vapid, :enabled) || false
end
|
#newsletter_notifications_at ⇒ Object
25
26
27
28
29
|
# File 'decidim-core/app/forms/decidim/notifications_settings_form.rb', line 25
def newsletter_notifications_at
return nil unless newsletter_notifications
Time.current
end
|
#notification_types ⇒ Object
31
32
33
34
35
36
37
38
39
40
41
|
# File 'decidim-core/app/forms/decidim/notifications_settings_form.rb', line 31
def notification_types
if notifications_from_followed && notifications_from_own_activity
"all"
elsif notifications_from_followed
"followed-only"
elsif notifications_from_own_activity
"own-only"
else
"none"
end
end
|