notifications_controller.rb 921 Bytes
Newer Older
1
class Profiles::NotificationsController < ApplicationController
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
2
3
4
5
  layout 'profile'

  def show
    @notification = current_user.notification
6
7
    @project_members = current_user.project_members
    @group_members = current_user.group_members
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
8
9
10
  end

  def update
11
12
13
14
15
    type = params[:notification_type]

    @saved = if type == 'global'
               current_user.notification_level = params[:notification_level]
               current_user.save
16
             elsif type == 'group'
17
               users_group = current_user.group_members.find(params[:notification_id])
18
19
               users_group.notification_level = params[:notification_level]
               users_group.save
20
             else
21
               users_project = current_user.project_members.find(params[:notification_id])
22
23
24
               users_project.notification_level = params[:notification_level]
               users_project.save
             end
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
25
26
  end
end