Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimothy Andrew <mail@timothyandrew.net>2016-06-14 06:36:53 +0300
committerTimothy Andrew <mail@timothyandrew.net>2016-06-14 06:36:53 +0300
commitd0bcba1105686c2306414a402bf33c85a08a17a6 (patch)
tree2922086316008cf86e864e1dd8a251fd4878cb04 /app/controllers/profiles
parentd754d99179f1ffe846fcc1d8e858163b39efc5dc (diff)
parentf34af6b83cc2663bb8a076f4df9c82047e5511ab (diff)
Merge remote-tracking branch 'origin/master' into 2979-personal-access-tokens
Diffstat (limited to 'app/controllers/profiles')
-rw-r--r--app/controllers/profiles/notifications_controller.rb23
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