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:
authorDouwe Maan <douwe@gitlab.com>2015-02-07 02:23:58 +0300
committerDouwe Maan <douwe@gitlab.com>2015-02-08 01:19:17 +0300
commit9dbd7e5aec921e43f3ea89c8e3357ca0174b0937 (patch)
treeda089409d276cb6b048c52cb91a4d74f829ffda1 /app/controllers/profiles/notifications_controller.rb
parentbc57ff0ef023db3d07f1adfa6a309fb4a24ed203 (diff)
Allow notification email to be set separately from primary email.
Closes #1932.
Diffstat (limited to 'app/controllers/profiles/notifications_controller.rb')
-rw-r--r--app/controllers/profiles/notifications_controller.rb22
1 files changed, 20 insertions, 2 deletions
diff --git a/app/controllers/profiles/notifications_controller.rb b/app/controllers/profiles/notifications_controller.rb
index 638d1f9789b..433c19189af 100644
--- a/app/controllers/profiles/notifications_controller.rb
+++ b/app/controllers/profiles/notifications_controller.rb
@@ -2,6 +2,7 @@ class Profiles::NotificationsController < ApplicationController
layout 'profile'
def show
+ @user = current_user
@notification = current_user.notification
@project_members = current_user.project_members
@group_members = current_user.group_members
@@ -11,8 +12,7 @@ class Profiles::NotificationsController < ApplicationController
type = params[:notification_type]
@saved = if type == 'global'
- current_user.notification_level = params[:notification_level]
- current_user.save
+ current_user.update_attributes(user_params)
elsif type == 'group'
users_group = current_user.group_members.find(params[:notification_id])
users_group.notification_level = params[:notification_level]
@@ -22,5 +22,23 @@ class Profiles::NotificationsController < ApplicationController
project_member.notification_level = params[:notification_level]
project_member.save
end
+
+ respond_to do |format|
+ format.html do
+ if @saved
+ flash[:notice] = "Notification settings saved"
+ else
+ flash[:alert] = "Failed to save new settings"
+ end
+
+ redirect_to :back
+ end
+
+ format.js
+ end
+ end
+
+ def user_params
+ params.require(:user).permit(:notification_email, :notification_level)
end
end