Skip to content

Commit

Permalink
delete checkout app
Browse files Browse the repository at this point in the history
  • Loading branch information
RustamovAkrom committed Oct 3, 2024
1 parent 31b9bd0 commit 0359b2e
Show file tree
Hide file tree
Showing 11 changed files with 62 additions and 126 deletions.
64 changes: 62 additions & 2 deletions apps/cart/views.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,63 @@
from django.shortcuts import render # noqa
from django.shortcuts import get_object_or_404, redirect, render
from django.views.decorators.http import require_POST
from apps.shop.models import Product
from apps.coupons.forms import CouponApplyForm
from .cart import Cart
from .forms import CartAddProductForm as CartUpdateProductForm
from .forms import CartAddProductForm as CartAddProductForm

# Create your views here.

@require_POST
def cart_add(request, product_id):
cart = Cart(request)
product = get_object_or_404(Product, id=product_id)
form = CartAddProductForm(request.POST)
if form.is_valid():
cd = form.cleaned_data
cart.add(
product=product,
qty=cd["quantity"],
)
return redirect("cart:cart_detail")


@require_POST
def cart_update(request, product_id):
cart = Cart(request)
product = get_object_or_404(Product, id=product_id)
form = CartUpdateProductForm(request.POST)
if form.is_valid():
cd = form.cleaned_data
cart.update(
product=product,
qty=cd["quantity"]
)
return redirect("cart:cart_detail")


@require_POST
def cart_remove(request, product_id):
cart = Cart(request)
product = get_object_or_404(Product, id=product_id)
cart.delete(product)
return redirect("cart:cart_detail")


@require_POST
def cart_detail(request):
cart = Cart(request)

for item in cart:
item["update_quantity_form"] = CartAddProductForm(
initial={"quantity": item["quantity"], "override": True}
)
coupon_apply_form = CouponApplyForm()

return render(
request,
"cart/detail.html",
{
"cart": cart,
"coupon_apply_form": coupon_apply_form,
}
)
Empty file removed apps/checkout/__init__.py
Empty file.
1 change: 0 additions & 1 deletion apps/checkout/admin.py

This file was deleted.

6 changes: 0 additions & 6 deletions apps/checkout/apps.py

This file was deleted.

7 changes: 0 additions & 7 deletions apps/checkout/choices.py

This file was deleted.

68 changes: 0 additions & 68 deletions apps/checkout/migrations/0001_initial.py

This file was deleted.

Empty file.
40 changes: 0 additions & 40 deletions apps/checkout/models.py

This file was deleted.

1 change: 0 additions & 1 deletion apps/checkout/tests.py

This file was deleted.

Empty file removed apps/checkout/urls.py
Empty file.
1 change: 0 additions & 1 deletion apps/checkout/views.py

This file was deleted.

0 comments on commit 0359b2e

Please sign in to comment.