Sha256: 8d6ae8cda9ed8b2725fad64254dfd8f62c1be094f524e6c911567aa1e750750c

Contents?: true

Size: 1.41 KB

Versions: 1

Compression:

Stored size: 1.41 KB

Contents

class NotificationsController < ApplicationController

  before_filter :authenticate_user!
  before_filter :get_mailbox, :get_actor
  before_filter :check_current_subject_is_owner, :only => [:show, :update, :destroy]
  
  def index
    @notifications = @mailbox.notifications.not_trashed.page(params[:page]).per(10)
  end

  def show
    
  end

  def new

  end

  def edit

  end

  def create

  end

  def update
    if params[:read].present?
      if params[:read].eql?("Read")
        @actor.read @notification
      elsif params[:read].eql?("Unread")
        @actor.unread @notification
      end
    end
    @notifications = @mailbox.notifications.not_trashed.page(params[:page]).per(10)
    render :action => :index
  end
  
  def update_all
    @notifications= @mailbox.notifications.all
    @actor.read @notifications
    @notifications = @mailbox.notifications.not_trashed.page(params[:page]).per(10)
    render :action => :index
  end

  def destroy
    @notification.receipt_for(@actor).move_to_trash
    redirect_to notifications_path
  end

  private

  def get_mailbox
    @mailbox = current_subject.mailbox
  end

  def get_actor
    @actor = Actor.normalize(current_subject)
  end


  def check_current_subject_is_owner
    
    @notification = Notification.find_by_id(params[:id])

    if @notification.nil? #TODO or !@notification.is_receiver?(@actor)
      redirect_to notifications_path
    return
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
social_stream-base-0.9.1 app/controllers/notifications_controller.rb