Skip to content
Extraits de code Groupes Projets
notifications_controller.rb 1,08 ko
Newer Older
maxwell's avatar
maxwell a validé
#   Copyright (c) 2010, Diaspora Inc.  This file is
#   licensed under the Affero General Public License version 3 or later.  See
#   the COPYRIGHT file.

class NotificationsController < ApplicationController
  before_filter :authenticate_user!
  respond_to :html, :json
maxwell's avatar
maxwell a validé

maxwell's avatar
maxwell a validé

  def update
Raphael's avatar
Raphael a validé
    note = Notification.where(:recipient_id => current_user.id, :id => params[:id]).first
maxwell's avatar
maxwell a validé
    if note
maxwell's avatar
maxwell a validé
      note.update_attributes(:unread => false)
maxwell's avatar
maxwell a validé
      render :nothing => true
    else
      render :nothing => true, :code => 404
    end
  end

  def index
    @notifications = Notification.find(:all, :conditions => {:recipient_id => current_user.id},
                                       :order => 'created_at desc', :include => [:target, {:actors => :profile}]).paginate :page => params[:page], :per_page => 25
MrZYX's avatar
MrZYX a validé
    @group_days = @notifications.group_by{|note| I18n.l(note.updated_at, :format => I18n.t('date.formats.fullmonth_day')) }
maxwell's avatar
maxwell a validé
  end
  def read_all
    Notification.where(:recipient_id => current_user.id).update_all(:unread => false)
    redirect_to aspects_path
maxwell's avatar
maxwell a validé
end