Class: Decidim::NotificationsSettingsForm
- Defined in:
- app/forms/decidim/notifications_settings_form.rb
Overview
The form object that handles the data behind updating a user’s notifications settings in her profile page.
Instance Method Summary collapse
- #direct_message_types ⇒ Object
- #map_model(user) ⇒ Object
- #newsletter_notifications_at ⇒ Object
- #notification_types ⇒ Object
- #user_is_moderator?(user) ⇒ Boolean
Instance Method Details
#direct_message_types ⇒ Object
41 42 43 |
# File 'app/forms/decidim/notifications_settings_form.rb', line 41 def allow_public_contact ? "all" : "followed-only" end |
#map_model(user) ⇒ Object
16 17 18 19 20 21 |
# File 'app/forms/decidim/notifications_settings_form.rb', line 16 def map_model(user) self. = user..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. == "all" end |
#newsletter_notifications_at ⇒ Object
23 24 25 26 27 |
# File 'app/forms/decidim/notifications_settings_form.rb', line 23 def return nil unless Time.current end |
#notification_types ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 |
# File 'app/forms/decidim/notifications_settings_form.rb', line 29 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 |
#user_is_moderator?(user) ⇒ Boolean
45 46 47 48 49 50 51 |
# File 'app/forms/decidim/notifications_settings_form.rb', line 45 def user_is_moderator?(user) Decidim.participatory_space_manifests.map do |manifest| participatory_space_type = manifest.model_class_name.constantize return true if participatory_space_type.moderators(user.organization).exists?(id: user.id) end false end |