summaryrefslogtreecommitdiff
path: root/app/controllers/projects
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2016-03-29 17:42:38 +0200
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2016-03-30 10:44:20 +0200
commit5583197e091e8f75ad9c99a1bbc46e6a0b7279d4 (patch)
tree949f3c92f4f951251bbbd3d9cfe8c5bd11878831 /app/controllers/projects
parentf8f68d6b8c5b5d85b4798257ae3ae4bf4ec8fadc (diff)
downloadgitlab-ce-5583197e091e8f75ad9c99a1bbc46e6a0b7279d4.tar.gz
Create NotificationSettings object only when user change value in dropdown
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'app/controllers/projects')
-rw-r--r--app/controllers/projects/notification_settings_controller.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/app/controllers/projects/notification_settings_controller.rb b/app/controllers/projects/notification_settings_controller.rb
new file mode 100644
index 00000000000..3ecf63d107f
--- /dev/null
+++ b/app/controllers/projects/notification_settings_controller.rb
@@ -0,0 +1,22 @@
+class Projects::NotificationSettingsController < Projects::ApplicationController
+ def create
+ notification_setting = project.notification_settings.new(notification_setting_params)
+ notification_setting.user = current_user
+ saved = notification_setting.save
+
+ render json: { saved: saved }
+ end
+
+ def update
+ notification_setting = project.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