diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-02-07 18:42:34 -0800 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-02-07 18:42:34 -0800 |
commit | 3cd036e315576b8cd56f16965be6c4293b641a20 (patch) | |
tree | 7704725af660790ca79980a6f8da2db5b3efddbc /app/controllers/profiles | |
parent | 49d6721329bd9fccf656bb750ee8f6c712852cf6 (diff) | |
parent | 9dbd7e5aec921e43f3ea89c8e3357ca0174b0937 (diff) | |
download | gitlab-ce-3cd036e315576b8cd56f16965be6c4293b641a20.tar.gz |
Merge branch 'notification_email'
Conflicts:
db/schema.rb
Diffstat (limited to 'app/controllers/profiles')
-rw-r--r-- | app/controllers/profiles/emails_controller.rb | 3 | ||||
-rw-r--r-- | app/controllers/profiles/notifications_controller.rb | 22 |
2 files changed, 23 insertions, 2 deletions
diff --git a/app/controllers/profiles/emails_controller.rb b/app/controllers/profiles/emails_controller.rb index f3f0e69b83a..4a65c978e5c 100644 --- a/app/controllers/profiles/emails_controller.rb +++ b/app/controllers/profiles/emails_controller.rb @@ -18,6 +18,9 @@ class Profiles::EmailsController < ApplicationController @email = current_user.emails.find(params[:id]) @email.destroy + current_user.set_notification_email + current_user.save if current_user.notification_email_changed? + respond_to do |format| format.html { redirect_to profile_emails_url } format.js { render nothing: true } 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 |