feat: update address working

This commit is contained in:
Pablo Moreno
2025-01-19 03:10:34 +01:00
parent f9e57c2339
commit b48f84c337
4 changed files with 39 additions and 4 deletions
+12
View File
@@ -14,6 +14,7 @@ from shop.models import (
WishlistedProduct,
)
from users.forms.info import UserInfoForm
from web.forms import CustomerAddressForm
from web.mixins import FilteredQuerysetMixin, PaginatedQuerysetMixin
from web.models import WebSettings
from web.settings import ANONYMOUS_CART_ID_COOKIE_NAME
@@ -178,6 +179,17 @@ class UserInfoComponentView(TemplateView):
return render(request, self.template_name, {"form": form})
def update_customer_address(request, pk):
customer_address = get_object_or_404(CustomerAddress, pk=pk, user=request.user)
form = CustomerAddressForm(request.POST, instance=customer_address)
if form.is_valid():
form.save()
return HttpResponse(status=200)
return HttpResponse(form.errors, status=400)
list_products = ListProducts.as_view()
list_wishlisted_products = ListWishlistedProducts.as_view()
wishlist_button = WishlistButton.as_view()