From 206f10cc96740b0a25f4f7f1ff7c944962a852cc Mon Sep 17 00:00:00 2001 From: Nathan Chapman Date: Wed, 25 May 2022 19:03:40 -0600 Subject: [PATCH] Add post only requirement on respective views --- src/core/tests/test_models.py | 4 +++- src/storefront/views.py | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/core/tests/test_models.py b/src/core/tests/test_models.py index 009faec..59935f9 100644 --- a/src/core/tests/test_models.py +++ b/src/core/tests/test_models.py @@ -2,7 +2,7 @@ from decimal import Decimal from django.test import TestCase from measurement.measures import Weight - +from accounts.models import User from core.models import ( Product, ProductPhoto, @@ -16,6 +16,8 @@ from core.models import ( class ProductModelTest(TestCase): + fixtures = ['accounts.json'] + @classmethod def setUpTestData(cls): Product.objects.create( diff --git a/src/storefront/views.py b/src/storefront/views.py index a8e4c4f..0c553db 100644 --- a/src/storefront/views.py +++ b/src/storefront/views.py @@ -65,6 +65,7 @@ class CartView(TemplateView): class CartAddProductView(SingleObjectMixin, FormView): model = Product form_class = AddToCartForm + http_method_names = ['post'] def get_success_url(self): return reverse('storefront:cart-detail') @@ -90,6 +91,7 @@ class CartAddProductView(SingleObjectMixin, FormView): class CartUpdateProductView(SingleObjectMixin, FormView): model = Product form_class = UpdateCartItemForm + http_method_names = ['post'] def get_success_url(self): return reverse('storefront:cart-detail') @@ -121,9 +123,9 @@ def cart_remove_product_view(request, pk, grind): class CouponApplyView(FormView): - template_name = 'contact.html' form_class = CouponApplyForm success_url = reverse_lazy('storefront:cart-detail') + http_method_names = ['post'] def form_valid(self, form): today = timezone.localtime(timezone.now()).date()