Class: Decidim::NotificationsSettingsController

Inherits:
ApplicationController show all
Includes:
UserProfile
Defined in:
app/controllers/decidim/notifications_settings_controller.rb

Overview

The controller to handle the user’s notifications settings page.

Instance Method Summary collapse

Methods included from UserProfile

#available_authorization_handlers

Instance Method Details

#showObject



10
11
12
13
# File 'app/controllers/decidim/notifications_settings_controller.rb', line 10

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

#updateObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/controllers/decidim/notifications_settings_controller.rb', line 15

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