Ejemplo n.º 1
0
def delete_item_from_cart(request):
    item_code = request.POST.get('license_code', None)
    if item_code is None:
        raise PermissionDenied
    cart = Cart(request)
    cart.remove(item_code)
    cart.save(request)
    return HttpResponse(json.dumps({'status': "ok"}), content_type="application/json")
Ejemplo n.º 2
0
def add_item_to_cart(request):
    item_code = request.POST.get('license_code', None)
    quantity = int(request.POST.get('quantity', None))
    if item_code and quantity is None:
        raise PermissionDenied
    if request.session.session_key is None:
        request.session.create()
    cart = Cart(request)
    cart.add(item_code, quantity)
    cart.save(request)
    return HttpResponse(json.dumps({'status': "ok"}), content_type="application/json")
Ejemplo n.º 3
0
 def post_ajax(self, request, *args, **kwargs):
     item_code = request.POST.get('license_code', None)
     quantity = int(request.POST.get('quantity', None))
     if item_code and quantity is None:
         raise PermissionDenied
     if request.session.session_key is None:
         request.session.create()
     cart = Cart(request)
     cart.add(item_code, quantity)
     cart.save(request)
     return self.render_json_response({"status": "ok"})
Ejemplo n.º 4
0
 def delete_ajax(self, request, *args, **kwargs):
     cart = Cart(request)
     cart.clear()
     cart.save(request)
     return self.render_json_response({"status": "ok"})