Sha256: 09bb434efcbcb15ed1fda57b3d62b5c6482ad29010af4b50220286fb0de5e62d

Contents?: true

Size: 959 Bytes

Versions: 72

Compression:

Stored size: 959 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: current_user
      @notifications_settings = form(NotificationsSettingsForm).from_model(current_user)
    end

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

72 entries across 72 versions & 1 rubygems

Version Path
decidim-core-0.23.3 app/controllers/decidim/notifications_settings_controller.rb
decidim-core-0.23.2 app/controllers/decidim/notifications_settings_controller.rb
decidim-core-0.23.1 app/controllers/decidim/notifications_settings_controller.rb
decidim-core-0.23.1.rc1 app/controllers/decidim/notifications_settings_controller.rb
decidim-core-0.23.0 app/controllers/decidim/notifications_settings_controller.rb
decidim-core-0.22.0 app/controllers/decidim/notifications_settings_controller.rb
decidim-core-0.21.0 app/controllers/decidim/notifications_settings_controller.rb
decidim-core-0.20.1 app/controllers/decidim/notifications_settings_controller.rb
decidim-core-0.20.0 app/controllers/decidim/notifications_settings_controller.rb
decidim-core-0.19.1 app/controllers/decidim/notifications_settings_controller.rb
decidim-core-0.18.1 app/controllers/decidim/notifications_settings_controller.rb
decidim-core-0.19.0 app/controllers/decidim/notifications_settings_controller.rb
decidim-core-0.17.2 app/controllers/decidim/notifications_settings_controller.rb
decidim-core-0.18.0 app/controllers/decidim/notifications_settings_controller.rb
decidim-core-0.17.1 app/controllers/decidim/notifications_settings_controller.rb
decidim-core-0.16.1 app/controllers/decidim/notifications_settings_controller.rb
decidim-core-0.17.0 app/controllers/decidim/notifications_settings_controller.rb
decidim-core-0.16.0 app/controllers/decidim/notifications_settings_controller.rb
decidim-core-0.15.2 app/controllers/decidim/notifications_settings_controller.rb
decidim-core-0.15.1 app/controllers/decidim/notifications_settings_controller.rb