summaryrefslogtreecommitdiff
path: root/app/controllers
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2016-03-29 18:59:03 +0200
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2016-03-30 10:44:20 +0200
commit26631f9981a826ebe4aeba726e9be2b813d2c5c5 (patch)
tree0e0cdbabeb3f0fd8b9cfdd2abf5db106d885cd06 /app/controllers
parent729fe42bff474535c9eebb0b73974a79756372b8 (diff)
downloadgitlab-ce-26631f9981a826ebe4aeba726e9be2b813d2c5c5.tar.gz
Change how notification settings in profile are rendered and updated
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/groups/notification_settings_controller.rb14
-rw-r--r--app/controllers/profiles/notifications_controller.rb28
2 files changed, 20 insertions, 22 deletions
diff --git a/app/controllers/groups/notification_settings_controller.rb b/app/controllers/groups/notification_settings_controller.rb
new file mode 100644
index 00000000000..78e43c83aba
--- /dev/null
+++ b/app/controllers/groups/notification_settings_controller.rb
@@ -0,0 +1,14 @@
+class Groups::NotificationSettingsController < Groups::ApplicationController
+ def update
+ notification_setting = group.notification_settings.where(user_id: current_user).find(params[:id])
+ saved = notification_setting.update_attributes(notification_setting_params)
+
+ render json: { saved: saved }
+ end
+
+ private
+
+ def notification_setting_params
+ params.require(:notification_setting).permit(:level)
+ end
+end
diff --git a/app/controllers/profiles/notifications_controller.rb b/app/controllers/profiles/notifications_controller.rb
index 0cca5d1e330..18ee55c839a 100644
--- a/app/controllers/profiles/notifications_controller.rb
+++ b/app/controllers/profiles/notifications_controller.rb
@@ -6,29 +6,13 @@ class Profiles::NotificationsController < Profiles::ApplicationController
end
def update
- type = params[:notification_type]
-
- @saved = if type == 'global'
- current_user.update_attributes(user_params)
- else
- notification_setting = current_user.notification_settings.find(params[:notification_id])
- notification_setting.level = params[:notification_level]
- notification_setting.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_back_or_default(default: profile_notifications_path)
- end
-
- format.js
+ if current_user.update_attributes(user_params)
+ flash[:notice] = "Notification settings saved"
+ else
+ flash[:alert] = "Failed to save new settings"
end
+
+ redirect_back_or_default(default: profile_notifications_path)
end
def user_params