#NEWLINE# def create_shipping_event( self , request , order , lines , quantities ) : #NEWLINE# #INDENT# code = request . POST [ 'shipping_event_type' ] #NEWLINE# try : #NEWLINE# #INDENT# event_type = ShippingEventType . _default_manager . get ( code = code ) #NEWLINE# #UNINDENT# except ShippingEventType . DoesNotExist : #NEWLINE# #INDENT# messages . error ( request , ( _ ( "The event type '%s' is not valid" ) % code ) ) #NEWLINE# return self . reload_page ( ) #NEWLINE# #UNINDENT# reference = request . POST . get ( 'reference' , None ) #NEWLINE# try : #NEWLINE# #INDENT# EventHandler ( ) . handle_shipping_event ( order , event_type , lines , quantities , reference = reference ) #NEWLINE# #UNINDENT# except order_exceptions . InvalidShippingEvent as e : #NEWLINE# #INDENT# messages . error ( request , ( _ ( 'Unable to create shipping event: %s' ) % e ) ) #NEWLINE# #UNINDENT# except order_exceptions . InvalidStatus as e : #NEWLINE# #INDENT# messages . error ( request , ( _ ( 'Unable to create shipping event: %s' ) % e ) ) #NEWLINE# #UNINDENT# except PaymentError as e : #NEWLINE# #INDENT# messages . error ( request , ( _ ( 'Unable to create shipping event due to payment error: %s' ) % e ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# messages . success ( request , _ ( 'Shipping event created' ) ) #NEWLINE# #UNINDENT# return self . reload_page ( )