@permission_required("core.manage_shop")
def add_shipping_price(request, shipping_method_id):
    """Adds given shipping price (via request body) to shipping method with
    give id.

    Returns JSON encoded data.
    """
    try:
        price = float(request.POST.get("price", 0))
    except __HOLE__:
        price = 0.0

    shipping_method = get_object_or_404(ShippingMethod, pk=shipping_method_id)
    shipping_method.prices.create(price=price)
    _update_price_positions(shipping_method)

    message = _(u"Price has been added")
    html = [["#prices", shipping_method_prices(request, shipping_method_id)]]

    result = json.dumps({
        "html": html,
        "message": message,
    }, cls=LazyEncoder)

    return HttpResponse(result, content_type='application/json')
dataset/ETHPy150Open diefenbach/django-lfs/lfs/manage/shipping_methods/views.py/add_shipping_price