Sha256: d166371c0f64368a53bf1ba962b235a6a8ed0f7daf2fd4afd3bfce443fbf474a

Contents?: true

Size: 939 Bytes

Versions: 7

Compression:

Stored size: 939 Bytes

Contents

# frozen_string_literal: true

require_dependency "decidim/application_controller"

module Decidim
  # The controller to handle the user's notifications settings page.
  class NotificationsSettingsController < ApplicationController
    include Decidim::UserProfile

    def show
      authorize! :show, current_user
      @notifications_settings = form(NotificationsSettingsForm).from_model(current_user)
    end

    def update
      authorize! :update, current_user
      @notifications_settings = form(NotificationsSettingsForm).from_params(params)

      UpdateNotificationsSettings.call(current_user, @notifications_settings) do
        on(:ok) do
          flash.now[:notice] = t("notifications_settings.update.success", scope: "decidim")
        end

        on(:invalid) do
          flash.now[:alert] = t("notifications_settings.update.error", scope: "decidim")
        end
      end

      render action: :show
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
decidim-core-0.4.2 app/controllers/decidim/notifications_settings_controller.rb
decidim-core-0.4.1 app/controllers/decidim/notifications_settings_controller.rb
decidim-core-0.4.0 app/controllers/decidim/notifications_settings_controller.rb
decidim-core-0.3.2 app/controllers/decidim/notifications_settings_controller.rb
decidim-core-0.3.1 app/controllers/decidim/notifications_settings_controller.rb
decidim-core-0.3.0 app/controllers/decidim/notifications_settings_controller.rb
decidim-core-0.2.0 app/controllers/decidim/notifications_settings_controller.rb