Sha256: 254a9c7e5ca824ede064aa37b05cad76b93a298a03ecbd55e2d332e2321808e9

Contents?: true

Size: 644 Bytes

Versions: 3

Compression:

Stored size: 644 Bytes

Contents

# frozen_string_literal: true

module Decidim
  # The form object that handles the data behind updating a user's
  # notifications settings in her profile page.
  class NotificationsSettingsForm < Form
    mimic :user

    attribute :email_on_notification
    attribute :newsletter_notifications

    validates :email_on_notification, presence: true
    validates :newsletter_notifications, presence: true

    def newsletter_notifications_at
      return nil unless newsletter_notifications
      Time.current
    end

    def map_model(model)
      self.newsletter_notifications = model.newsletter_notifications_at.present?
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
decidim-core-0.15.2 app/forms/decidim/notifications_settings_form.rb
decidim-core-0.15.1 app/forms/decidim/notifications_settings_form.rb
decidim-core-0.15.0 app/forms/decidim/notifications_settings_form.rb