diff options
author | James Lopez <james@jameslopez.es> | 2016-06-16 12:12:27 +0200 |
---|---|---|
committer | James Lopez <james@jameslopez.es> | 2016-06-16 12:12:28 +0200 |
commit | 13e37a3ee5c943525a99481b855d654e97e8597c (patch) | |
tree | 21cd6acfe884046eeb32bc23095b6a2f9f02c8cb /app/controllers/profiles/notifications_controller.rb | |
parent | 9be06bbbb40a64b060fe9042fc84817551dfed08 (diff) | |
download | gitlab-ce-13e37a3ee5c943525a99481b855d654e97e8597c.tar.gz |
squashed merge and fixed conflicts
Diffstat (limited to 'app/controllers/profiles/notifications_controller.rb')
-rw-r--r-- | app/controllers/profiles/notifications_controller.rb | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/app/controllers/profiles/notifications_controller.rb b/app/controllers/profiles/notifications_controller.rb index 18ee55c839a..40d1906a53f 100644 --- a/app/controllers/profiles/notifications_controller.rb +++ b/app/controllers/profiles/notifications_controller.rb @@ -1,12 +1,13 @@ class Profiles::NotificationsController < Profiles::ApplicationController def show - @user = current_user - @group_notifications = current_user.notification_settings.for_groups - @project_notifications = current_user.notification_settings.for_projects + @user = current_user + @group_notifications = current_user.notification_settings.for_groups + @project_notifications = current_user.notification_settings.for_projects + @global_notification_setting = current_user.global_notification_setting end def update - if current_user.update_attributes(user_params) + if current_user.update_attributes(user_params) && update_notification_settings flash[:notice] = "Notification settings saved" else flash[:alert] = "Failed to save new settings" @@ -16,6 +17,18 @@ class Profiles::NotificationsController < Profiles::ApplicationController end def user_params - params.require(:user).permit(:notification_email, :notification_level) + params.require(:user).permit(:notification_email) + end + + def global_notification_setting_params + params.require(:global_notification_setting).permit(:level) + end + + private + + def update_notification_settings + return true unless global_notification_setting_params + + current_user.global_notification_setting.update_attributes(global_notification_setting_params) end end |