#NEWLINE# def send( self , person , group = None ) : #NEWLINE# #INDENT# '\n        Sends this newsletter to "person" with optional "group".\n        This works only with newsletters which are workflow newsletters.\n        ' #NEWLINE# if ( not self . is_workflow ( ) ) : #NEWLINE# #INDENT# raise exceptions . AttributeError ( 'only newsletters with type workflow can be sent' ) #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# if group : #NEWLINE# #INDENT# ctype = ContentType . objects . get_for_model ( group ) #NEWLINE# job = self . jobs . get ( content_type__pk = ctype . id , object_id = group . id ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# job = self . jobs . get ( content_type = None ) #NEWLINE# #UNINDENT# #UNINDENT# except models . ObjectDoesNotExist : #NEWLINE# #INDENT# if group : #NEWLINE# #INDENT# kw = { #NEWLINE# #INDENT# 'group_object' : group , #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# kw = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# job = self . jobs . create ( status = 32 , ** kw ) #NEWLINE# #UNINDENT# self . replace_links ( job ) #NEWLINE# self . prepare_to_send ( ) #NEWLINE# mail = job . create_mail ( person ) #NEWLINE# try : #NEWLINE# #INDENT# message = mail . get_message ( ) #NEWLINE# message . send ( ) #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# raise #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# mail . mark_sent ( )