#NEWLINE# def form_valid( self , form ) : #NEWLINE# #INDENT# account = form . save ( ) #NEWLINE# source = form . get_source_account ( ) #NEWLINE# amount = form . cleaned_data [ 'initial_amount' ] #NEWLINE# try : #NEWLINE# #INDENT# facade . transfer ( source , account , amount , user = self . request . user , description = _ ( 'Creation of account' ) ) #NEWLINE# #UNINDENT# except exceptions . AccountException as e : #NEWLINE# #INDENT# messages . error ( self . request , ( _ ( 'Account created but unable to load funds onto new account: %s' ) % e ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# messages . success ( source . request , ( _ ( "New account created with code '%s'" ) % account . code ) ) #NEWLINE# #UNINDENT# return http . HttpResponseRedirect ( reverse ( 'accounts-detail' , kwargs = { #NEWLINE# #INDENT# 'pk' : account . id , #NEWLINE# #UNINDENT# } ) )