BigW Consortium Gitlab

notifications_controller.rb 915 Bytes
Newer Older
1
class Profiles::NotificationsController < ApplicationController
2 3 4 5
  layout 'profile'

  def show
    @notification = current_user.notification
6
    @users_projects = current_user.users_projects
7
    @users_groups = current_user.users_groups
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 17 18 19
             elsif type == 'group'
               users_group = current_user.users_groups.find(params[:notification_id])
               users_group.notification_level = params[:notification_level]
               users_group.save
20 21 22 23 24
             else
               users_project = current_user.users_projects.find(params[:notification_id])
               users_project.notification_level = params[:notification_level]
               users_project.save
             end
25 26
  end
end