#NEWLINE# def accept_answer( self , post , user = None ) : #NEWLINE# #INDENT# 'Accept a post as answer.' #NEWLINE# assert ( ( post is None ) or ( post . topic == self ) ) , 'that post does not belong to the topic' #NEWLINE# if ( self . answer is not None ) : #NEWLINE# #INDENT# self . answer . is_answer = False #NEWLINE# atomic_add ( self . answer . author , 'reputation' , ( - settings . REPUTATION_MAP [ 'LOSE_ON_LOST_ANSWER' ] ) ) #NEWLINE# #UNINDENT# if ( user is None ) : #NEWLINE# #INDENT# user = ( ( post and post . author ) or self . author ) #NEWLINE# #UNINDENT# if ( post is not None ) : #NEWLINE# #INDENT# post . is_answer = True #NEWLINE# atomic_add ( post . author , 'reputation' , settings . REPUTATION_MAP [ 'GAIN_ON_ACCEPTED_ANSWER' ] ) #NEWLINE# self . answer_author = post . author #NEWLINE# self . answer_date = post . created #NEWLINE# #UNINDENT# self . answer = post #NEWLINE# try_award ( 'accept' , user , user , post )