#NEWLINE# def get_context_data( self , **kwargs ) : #NEWLINE# #INDENT# context = super ( UserHomePageView , self ) . get_context_data ( ** kwargs ) #NEWLINE# other_friends = None #NEWLINE# username = name = context . get ( 'username' , None ) #NEWLINE# if name : #NEWLINE# #INDENT# user = other_user = get_object_or_404 ( User , username = name ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# user = other_user = self . request . user #NEWLINE# #UNINDENT# if ( self . request . user == other_user ) : #NEWLINE# #INDENT# context [ 'is_me' ] = True #NEWLINE# is_friend = False #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if self . request . user . is_authenticated ( ) : #NEWLINE# #INDENT# is_friend = context [ 'is_friend' ] = Friendship . objects . are_friends ( self . request . user , other_user ) #NEWLINE# context [ 'is_following' ] = Following . objects . is_following ( self . request . user , other_user ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# is_friend = False #NEWLINE# #UNINDENT# #UNINDENT# context [ 'other_friends' ] = Friendship . objects . friends_for_user ( other_user ) #NEWLINE# context [ 'other_user' ] = other_user #NEWLINE# tweets = [ TimeLineItem ( item , item . sent , item . sender , 'timeline/_tweet.html' ) for item in Tweet . objects . all ( ) . filter ( sender_id = user . id , sender_type__model = 'user' ) . order_by ( '-sent' ) [ : 32 ] ] #NEWLINE# context [ 'latest_blogs' ] = Post . objects . all ( ) . filter ( status = 2 , author = user ) . order_by ( '-publish' ) [ : 32 ] #NEWLINE# posts = [ TimeLineItem ( item , item . updated_at , item . author , 'timeline/_post.html' ) for item in context [ 'latest_blogs' ] ] #NEWLINE# image_filter = Q ( is_public = True , member = user ) #NEWLINE# if self . request . user . is_authenticated ( ) : #NEWLINE# #INDENT# image_filter = ( image_filter | Q ( member = user , member__in = friend_set_for ( self . request . user ) ) ) #NEWLINE# #UNINDENT# context [ 'latest_photos' ] = Image . objects . all ( ) . filter ( image_filter ) . order_by ( '-date_added' ) [ : 32 ] #NEWLINE# images = [ TimeLineItem ( item , item . date_added , item . member , 'timeline/_photo.html' ) for item in context [ 'latest_photos' ] ] #NEWLINE# context [ 'latest_tracks' ] = Track . objects . all ( ) . filter ( user = user ) . order_by ( '-created_at' ) [ : 32 ] #NEWLINE# tracks = [ TimeLineItem ( item , item . updated_at , item . user , 'timeline/_track.html' ) for item in context [ 'latest_tracks' ] ] #NEWLINE# comments = [ TimeLineItem ( item , item . date_submitted , item . user , 'timeline/_comment.html' ) for item in ThreadedComment . objects . all ( ) . filter ( user = user ) . order_by ( '-date_submitted' ) [ : 32 ] ] #NEWLINE# items = merge ( tweets , images , posts , tracks , comments , field = 'date' ) [ : 16 ] #NEWLINE# for ( index , item ) in enumerate ( items ) : #NEWLINE# #INDENT# item . index = ( index + 1 ) #NEWLINE# #UNINDENT# context [ 'timelineitems' ] = group_comments ( items ) #NEWLINE# context [ 'prefix_sender' ] = True #NEWLINE# invite_form = None #NEWLINE# if is_friend : #NEWLINE# #INDENT# previous_invitations_to = None #NEWLINE# previous_invitations_from = None #NEWLINE# if ( self . request . method == 'POST' ) : #NEWLINE# #INDENT# if ( self . request . POST . get ( 'action' ) == 'remove' ) : #NEWLINE# #INDENT# Friendship . objects . remove ( self . request . user , other_user ) #NEWLINE# messages . add_message ( self . request , messages . SUCCESS , ( ugettext ( 'You have removed %(from_user)s from friends' ) % { #NEWLINE# #INDENT# 'from_user' : other_user , #NEWLINE# #UNINDENT# } ) ) #NEWLINE# is_friend = False #NEWLINE# invite_form = InviteFriendForm ( self . request . user , { #NEWLINE# #INDENT# 'to_user' : username , #NEWLINE# 'message' : ugettext ( "Let's be friends!" ) , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( self . request . user . is_authenticated ( ) and ( self . request . method == 'POST' ) ) : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# invite_form = InviteFriendForm ( self . request . user , { #NEWLINE# #INDENT# 'to_user' : username , #NEWLINE# 'message' : ugettext ( "Let's be friends!" ) , #NEWLINE# #UNINDENT# } ) #NEWLINE# previous_invitations_to = None #NEWLINE# previous_invitations_from = None #NEWLINE# #UNINDENT# #UNINDENT# context [ 'invite_form' ] = invite_form #NEWLINE# context [ 'previous_invitations_to' ] = previous_invitations_to #NEWLINE# context [ 'previous_invitations_from' ] = previous_invitations_from #NEWLINE# context [ 'other_friends' ] = other_friends #NEWLINE# return context