#NEWLINE# def create_if_new( self , product , contact , details ) : #NEWLINE# #INDENT# encoded = simplejson . dumps ( details ) #NEWLINE# products = ProductWish . objects . filter ( product = product , contact = contact , _details = encoded ) #NEWLINE# if ( products and ( len ( products ) > 0 ) ) : #NEWLINE# #INDENT# wish = products [ 0 ] #NEWLINE# if ( len ( products ) > 1 ) : #NEWLINE# #INDENT# for p in products [ 1 : ] : #NEWLINE# #INDENT# p . delete ( ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# wish = ProductWish ( product = product , contact = contact ) #NEWLINE# wish . details = details #NEWLINE# wish . save ( ) #NEWLINE# #UNINDENT# return wish