notifications_controller.rb 829 字节
Newer Older
D
Douwe Maan 已提交
1
class Profiles::NotificationsController < Profiles::ApplicationController
D
Dmitriy Zaporozhets 已提交
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
D
Dmitriy Zaporozhets 已提交
7 8 9
  end

  def update
10
    result = Users::UpdateService.new(current_user, user_params).execute
11 12

    if result[:status] == :success
13 14 15
      flash[:notice] = "Notification settings saved"
    else
      flash[:alert] = "Failed to save new settings"
16
    end
17 18

    redirect_back_or_default(default: profile_notifications_path)
19 20 21
  end

  def user_params
22
    params.require(:user).permit(:notification_email, :notified_of_own_activity)
D
Dmitriy Zaporozhets 已提交
23 24
  end
end