debian-mirror-gitlab/app/controllers/profiles/notifications_controller.rb

43 lines
1.3 KiB
Ruby
Raw Normal View History

2015-09-11 14:41:01 +05:30
class Profiles::NotificationsController < Profiles::ApplicationController
2014-09-02 18:07:02 +05:30
def show
2015-04-26 12:48:37 +05:30
@user = current_user
2014-09-02 18:07:02 +05:30
@notification = current_user.notification
2015-04-26 12:48:37 +05:30
@project_members = current_user.project_members
@group_members = current_user.group_members
2014-09-02 18:07:02 +05:30
end
def update
type = params[:notification_type]
@saved = if type == 'global'
2015-04-26 12:48:37 +05:30
current_user.update_attributes(user_params)
2014-09-02 18:07:02 +05:30
elsif type == 'group'
2015-04-26 12:48:37 +05:30
group_member = current_user.group_members.find(params[:notification_id])
group_member.notification_level = params[:notification_level]
group_member.save
2014-09-02 18:07:02 +05:30
else
2015-04-26 12:48:37 +05:30
project_member = current_user.project_members.find(params[:notification_id])
project_member.notification_level = params[:notification_level]
project_member.save
2014-09-02 18:07:02 +05:30
end
2015-04-26 12:48:37 +05:30
respond_to do |format|
format.html do
if @saved
flash[:notice] = "Notification settings saved"
else
flash[:alert] = "Failed to save new settings"
end
2015-10-24 18:46:33 +05:30
redirect_back_or_default(default: profile_notifications_path)
2015-04-26 12:48:37 +05:30
end
format.js
end
end
def user_params
params.require(:user).permit(:notification_email, :notification_level)
2014-09-02 18:07:02 +05:30
end
end