#NEWLINE# def handle( self , * args , **options ) : #NEWLINE# #INDENT# translation . activate ( 'en-us' ) #NEWLINE# billing_date = None #NEWLINE# if options [ 'billing_date' ] : #NEWLINE# #INDENT# billing_date = dt . strptime ( options [ 'billing_date' ] , '%Y-%m-%d' ) . date ( ) #NEWLINE# #UNINDENT# docs_generator = DocumentsGenerator ( ) #NEWLINE# if options [ 'subscription_id' ] : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# subscription_id = options [ 'subscription_id' ] #NEWLINE# logger . info ( 'Generating for subscription with id=%s; billing_date=%s.' , subscription_id , billing_date ) #NEWLINE# subscription = Subscription . objects . get ( id = subscription_id ) #NEWLINE# docs_generator . generate ( subscription = subscription , billing_date = billing_date ) #NEWLINE# self . stdout . write ( 'Done. You can have a Club-Mate now. :)' ) #NEWLINE# #UNINDENT# except Subscription . DoesNotExist : #NEWLINE# #INDENT# msg = 'The subscription with the provided id does not exist.' #NEWLINE# self . stdout . write ( msg ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# logger . info ( 'Generating for all the available subscriptions; billing_date=%s.' , billing_date ) #NEWLINE# docs_generator . generate ( billing_date = billing_date ) #NEWLINE# self . stdout . write ( 'Done. You can have a Club-Mate now. :)' )