<commit_before>from cart import Cart
from django.utils import translation
from mailtemplates.models import EMailTemplate
from payment.models import PrePayment
from payment.services.paypal import paypal
from shop.checkout_wizard import condition_step_3, CheckoutWizardBase
from shop.models import Product, Order
from django.http import Http404, HttpResponseNotAllowed
from django.shortcuts import redirect, render_to_response, render
from django.template import RequestContext


def index_view(request):
    return render_to_response("cuescience_shop/cart/index.html", RequestContext(request))


def add_view(request, product_id):
    if request.method != "POST":
        return HttpResponseNotAllowed(["POST"])

    next = request.GET.get("next", "/")

    cart = Cart(request)
    try:
        product = Product.objects.get(pk=product_id)
    except Product.DoesNotExist:
        raise Http404

    cart.add(product, product.price)

    return redirect(next)


def remove_view(request, product_id):
    if request.method != "POST":
        return HttpResponseNotAllowed(["POST"])

    next = request.GET.get("next", "/")

    cart = Cart(request)
    try:
        product = Product.objects.get(pk=product_id)
    except Product.DoesNotExist:
        raise Http404

    cart.remove(product)

    return redirect(next)


def update_view(request):
    if request.method != "POST":
        return HttpResponseNotAllowed(["POST"])

    next = request.GET.get("next", "/")

    cart = Cart(request)
    for item in cart:
        quantity = request.POST.get("quantity-{0}".format(item.product.pk), None)
        isNone = quantity is None

        if isNone:
            continue
        isSame = int(quantity) == item.quantity
        if isSame:
            continue

        quantity = int(quantity)
        if quantity == 0:
            item.delete()
            return redirect(next)

        item.quantity = quantity
        item.save()

    return redirect(next)


class CheckoutWizard(CheckoutWizardBase):
    template_name = "cuescience_shop/cart/wizard.html"

    def create_paypalpayment(self, cart):
        paypalservice = paypal.PayPalService()
<commit_msg>bug fix for update view<commit_after>from cart import Cart
from django.utils import translation
from mailtemplates.models import EMailTemplate
from payment.models import PrePayment
from payment.services.paypal import paypal
from shop.checkout_wizard import condition_step_3, CheckoutWizardBase
from shop.models import Product, Order
from django.http import Http404, HttpResponseNotAllowed
from django.shortcuts import redirect, render_to_response, render
from django.template import RequestContext


def index_view(request):
    return render_to_response("cuescience_shop/cart/index.html", RequestContext(request))


def add_view(request, product_id):
    if request.method != "POST":
        return HttpResponseNotAllowed(["POST"])

    next = request.GET.get("next", "/")

    cart = Cart(request)
    try:
        product = Product.objects.get(pk=product_id)
    except Product.DoesNotExist:
        raise Http404

    cart.add(product, product.price)

    return redirect(next)


def remove_view(request, product_id):
    if request.method != "POST":
        return HttpResponseNotAllowed(["POST"])

    next = request.GET.get("next", "/")

    cart = Cart(request)
    try:
        product = Product.objects.get(pk=product_id)
    except Product.DoesNotExist:
        raise Http404

    cart.remove(product)

    return redirect(next)


def update_view(request):
    if request.method != "POST":
        return HttpResponseNotAllowed(["POST"])

    next = request.GET.get("next", "/")

    cart = Cart(request)
    for item in cart:
        quantity = request.POST.get("quantity-{0}".format(item.product.pk), None)
        isNone = quantity is None

        if isNone:
            continue
        isSame = int(quantity) == item.quantity
        if isSame:
            continue

        quantity = int(quantity)
        if quantity == 0:
            item.delete()
            continue

        item.quantity = quantity
        item.save()

    return redirect(next)


class CheckoutWizard(CheckoutWizardBase):
    template_name = "cuescience_shop/cart/wizard.html"

    def create_paypalpayment(self, cart):
        paypalservice = paypal.PayPalService()

{'fraction_non_alphanumeric': 0.09715475364330327, 'fraction_numerical': 0.005551700208188758, 'mean_word_length': 3.1737451737451736, 'pattern_counts': {'":': 6, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5867112', 'n_tokens_mistral': 1269, 'n_tokens_neox': 1210, 'n_words': 299}