BigW Consortium Gitlab

notifications_controller.rb 744 Bytes
Newer Older
1
class Profiles::NotificationsController < Profiles::ApplicationController
2
  def show
3
    @user                        = current_user
4 5
    @group_notifications         = current_user.notification_settings.for_groups.order(:id)
    @project_notifications       = current_user.notification_settings.for_projects.order(:id)
6
    @global_notification_setting = current_user.global_notification_setting
7 8 9
  end

  def update
10
    if current_user.update_attributes(user_params)
11 12 13
      flash[:notice] = "Notification settings saved"
    else
      flash[:alert] = "Failed to save new settings"
14
    end
15 16

    redirect_back_or_default(default: profile_notifications_path)
17 18 19
  end

  def user_params
20
    params.require(:user).permit(:notification_email)
21 22
  end
end