<s> from django . utils import timezone as datetime <EOL> from . import signals <EOL> from . tasks import dispatch_action <EOL> class Timeline ( object ) : <EOL> def __init__ ( self , instance , * args , ** kwargs ) : <EOL> from . import app <EOL> self . instance = instance <EOL> self . backend = kwargs . pop ( '<STR_LIT>' , app . backend ) <EOL> def mark_as_read ( self , timestamp = None ) : <EOL> if timestamp is None : <EOL> timestamp = datetime . now ( ) <EOL> self . backend . mark_as_read ( self . instance , timestamp = timestamp ) <EOL> def get_unread_count ( self , action = None , target = None ) : <EOL> read_at = self . read_at or <NUM_LIT:0> <EOL> return self . backend . get_unread_count ( self . instance , read_at , action = action , target = target ) <EOL> @ property <EOL> def read_at ( self ) : <EOL> return self . backend . get_read_at ( self . instance ) <EOL> def get_private ( self , action = None , target = None , desc = True ) : <EOL> return self . backend . get_private ( self . instance , action = action , target = target , desc = desc ) <EOL> def get_public ( self , action = None , target = None , desc = True ) : <EOL> return self . backend . get_public ( self . instance , action = action , target = target , desc = desc ) <EOL> def get_private_count ( self , action = None , target = None ) : <EOL> return self . backend . get_private_count ( self . instance , action = action , target = target ) <EOL> def get_public_count ( self , action = None , target = None , desc = True ) : <EOL> return self . backend . get_public_count ( self . instance , action = action , target = target ) <EOL> def delete ( self , action , dispatch = True ) : <EOL> origin = action . __class__ <EOL> if dispatch : <EOL> signals . pre_delete . send ( sender = origin , <EOL> instance = self . instance , <EOL> action = action ) <EOL> self . backend . delete ( self . instance , action ) <EOL> if dispatch : <EOL> signals . post_delete . send ( sender = origin , <EOL> instance = self . instance , <EOL> action = action ) <EOL> def save ( self , action , dispatch = True ) : <EOL> from sequere . models import get_followers_count <EOL> origin = action . __class__ <EOL> if dispatch : <EOL> signals . pre_save . send ( sender = origin , <EOL> instance = self . instance , <EOL> action = action ) <EOL> self . backend . save ( self . instance , action ) <EOL> if action . actor == self . instance and get_followers_count ( self . instance ) > <NUM_LIT:0> : <EOL> dispatch_action . delay ( action . uid , dispatch = dispatch ) <EOL> if dispatch : <EOL> signals . post_save . send ( sender = origin , <EOL> instance = self . instance , <EOL> action = action ) </s>
