diff options
Diffstat (limited to 'pyblackbird_cc/payments')
-rw-r--r-- | pyblackbird_cc/payments/tests/test_views.py | 7 | ||||
-rw-r--r-- | pyblackbird_cc/payments/urls.py | 2 | ||||
-rw-r--r-- | pyblackbird_cc/payments/views.py | 4 |
3 files changed, 8 insertions, 5 deletions
diff --git a/pyblackbird_cc/payments/tests/test_views.py b/pyblackbird_cc/payments/tests/test_views.py index 0b469b5..7d0f8b5 100644 --- a/pyblackbird_cc/payments/tests/test_views.py +++ b/pyblackbird_cc/payments/tests/test_views.py @@ -12,5 +12,8 @@ def test_cart_view(client, user): @pytest.mark.django_db -def test_add_resource_to_cart(resource, user): - url = reverse("payments:add_to_cart", args=[resource.pk]) +def test_add_resource_to_cart(client, resource, user): + url = reverse("payments:add_to_cart", kwargs={"resource_id": resource.id}) + client.force_login(user) + response = client.get(url) + assert response.status_code == 200 diff --git a/pyblackbird_cc/payments/urls.py b/pyblackbird_cc/payments/urls.py index d294aab..72f6678 100644 --- a/pyblackbird_cc/payments/urls.py +++ b/pyblackbird_cc/payments/urls.py @@ -15,7 +15,7 @@ urlpatterns = [ views.CreateCheckoutSessionView.as_view(), name="create-checkout-session", ), - path("add-to-card/<int:pk>", views.add_to_cart, name="add_to_cart"), + path("add-to-card/<int:resource_id>", views.add_to_cart, name="add_to_cart"), path("landing/", views.ProductLandingPageView.as_view(), name="landing"), # path("webhook/", views.webhook, name="webhook"), ] diff --git a/pyblackbird_cc/payments/views.py b/pyblackbird_cc/payments/views.py index 6863869..6ca31d8 100644 --- a/pyblackbird_cc/payments/views.py +++ b/pyblackbird_cc/payments/views.py @@ -55,9 +55,9 @@ def add_to_cart(request, resource_id): resource = get_object_or_404(Resource, id=resource_id) cart, created = ShoppingCart.objects.get_or_create(user=request.user) cart_item, created = CartItem.objects.get_or_create(cart=cart, resource=resource) - cart_item.quantity += 1 + # cart_item.quantity += 1 cart_item.save() - return redirect("cart_detail") + return render(request, "payments/cart_detail.html", {"cart": cart}) @login_required |