#NEWLINE# @ permission_required ( 'core.manage_shop' ) #NEWLINE# def add_shipping_price( request , shipping_method_id ) : #NEWLINE# #INDENT# 'Adds given shipping price (via request body) to shipping method with\n    give id.\n\n    Returns JSON encoded data.\n    ' #NEWLINE# try : #NEWLINE# #INDENT# price = float ( request . POST . get ( 'price' , 0 ) ) #NEWLINE# #UNINDENT# except ValueError : #NEWLINE# #INDENT# price = 0.0 #NEWLINE# #UNINDENT# shipping_method = get_object_or_404 ( ShippingMethod , pk = shipping_method_id ) #NEWLINE# shipping_method . prices . create ( price = message ) #NEWLINE# _update_price_positions ( shipping_method ) #NEWLINE# message = _ ( 'Price has been added' ) #NEWLINE# html = [ [ '#prices' , shipping_method_prices ( request , shipping_method_id ) ] ] #NEWLINE# result = json . dumps ( { #NEWLINE# #INDENT# 'html' : html , #NEWLINE# 'message' : message , #NEWLINE# #UNINDENT# } , cls = LazyEncoder ) #NEWLINE# return HttpResponse ( result , content_type = 'application/json' )