#NEWLINE# @ permission_required ( 'core.manage_shop' ) #NEWLINE# def save_shipping_method_data( request , shipping_method_id ) : #NEWLINE# #INDENT# 'Saves shipping data (via request body) to the shipping method with passed\n    id.\n\n    This is called via an AJAX request and returns JSON encoded data.\n    ' #NEWLINE# shipping_method = ShippingMethod . objects . get ( pk = shipping_method_id ) #NEWLINE# shipping_form = ShippingMethodForm ( instance = shipping_method , data = request . POST , files = request . FILES ) #NEWLINE# if shipping_form . is_valid ( ) : #NEWLINE# #INDENT# shipping_form . save ( ) #NEWLINE# shipping_form = ShippingMethodForm ( instance = shipping_method ) #NEWLINE# if request . POST . get ( 'delete_image' ) : #NEWLINE# #INDENT# shipping_method . image . delete ( ) #NEWLINE# #UNINDENT# message = _ ( 'Shipping method has been saved.' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# message = _ ( 'Please correct the indicated errors.' ) #NEWLINE# #UNINDENT# html = [ [ '#data' , shipping_method_data ( request , shipping_method . id , shipping_form ) ] , [ '#shipping-methods' , shipping_methods ( request ) ] ] #NEWLINE# result = json . dumps ( { #NEWLINE# #INDENT# 'html' : html , #NEWLINE# 'message' : message , #NEWLINE# #UNINDENT# } , cls = LazyEncoder ) #NEWLINE# return HttpResponse ( result , content_type = 'application/json' )