Sha256: c663051048fc1d17541ec30a1457e913fe3d9b71aa82afd3b344f48b1c7cb9fc

Contents?: true

Size: 935 Bytes

Versions: 8

Compression:

Stored size: 935 Bytes

Contents

# frozen_string_literal: true

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

    def show
      enforce_permission_to(:read, :user, current_user:)
      @notifications_settings = form(NotificationsSettingsForm).from_model(current_user)
    end

    def update
      enforce_permission_to(:update, :user, 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

8 entries across 8 versions & 1 rubygems

Version Path
decidim-core-0.28.5 app/controllers/decidim/notifications_settings_controller.rb
decidim-core-0.28.4 app/controllers/decidim/notifications_settings_controller.rb
decidim-core-0.28.3 app/controllers/decidim/notifications_settings_controller.rb
decidim-core-0.28.2 app/controllers/decidim/notifications_settings_controller.rb
decidim-core-0.28.1 app/controllers/decidim/notifications_settings_controller.rb
decidim-core-0.28.0 app/controllers/decidim/notifications_settings_controller.rb
decidim-core-0.28.0.rc5 app/controllers/decidim/notifications_settings_controller.rb
decidim-core-0.28.0.rc4 app/controllers/decidim/notifications_settings_controller.rb