BigW Consortium Gitlab

notifications_controller.rb 630 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
    @project_notifications = current_user.notification_settings.for_projects
6 7 8
  end

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

    redirect_back_or_default(default: profile_notifications_path)
16 17 18 19
  end

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