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.27.9 app/controllers/decidim/notifications_settings_controller.rb
decidim-core-0.27.8 app/controllers/decidim/notifications_settings_controller.rb
decidim-core-0.27.7 app/controllers/decidim/notifications_settings_controller.rb
decidim-core-0.27.6 app/controllers/decidim/notifications_settings_controller.rb
decidim-core-0.26.10 app/controllers/decidim/notifications_settings_controller.rb
decidim-core-0.26.9 app/controllers/decidim/notifications_settings_controller.rb
decidim-core-0.27.5 app/controllers/decidim/notifications_settings_controller.rb
decidim-core-0.26.8 app/controllers/decidim/notifications_settings_controller.rb
decidim-core-0.27.4 app/controllers/decidim/notifications_settings_controller.rb
decidim-core-0.27.3 app/controllers/decidim/notifications_settings_controller.rb
decidim-core-0.26.7 app/controllers/decidim/notifications_settings_controller.rb
decidim-core-0.26.5 app/controllers/decidim/notifications_settings_controller.rb
decidim-core-0.27.2 app/controllers/decidim/notifications_settings_controller.rb
decidim-core-0.27.1 app/controllers/decidim/notifications_settings_controller.rb
decidim-core-0.26.4 app/controllers/decidim/notifications_settings_controller.rb
decidim-core-0.27.0 app/controllers/decidim/notifications_settings_controller.rb
decidim-core-0.26.3 app/controllers/decidim/notifications_settings_controller.rb
decidim-core-0.27.0.rc2 app/controllers/decidim/notifications_settings_controller.rb
decidim-core-0.27.0.rc1 app/controllers/decidim/notifications_settings_controller.rb
decidim-core-0.26.2 app/controllers/decidim/notifications_settings_controller.rb