Sha256: 2acffbbaad9f05d720319d3e20c9957bea9e79b1792a14516c1c9595a946a462

Contents?: true

Size: 938 Bytes

Versions: 5

Compression:

Stored size: 938 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

5 entries across 5 versions & 1 rubygems

Version Path
decidim-core-0.1.0 app/controllers/decidim/notifications_settings_controller.rb
decidim-core-0.0.8.1 app/controllers/decidim/notifications_settings_controller.rb
decidim-core-0.0.7 app/controllers/decidim/notifications_settings_controller.rb
decidim-core-0.0.6 app/controllers/decidim/notifications_settings_controller.rb
decidim-core-0.0.5 app/controllers/decidim/notifications_settings_controller.rb