@@ -16,7 +22,7 @@
focus:ring-primary-600 focus:border-primary-600 block w-full p-2.5 dark:bg-gray-700
dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500
dark:focus:border-primary-500"
- id="address_full_name" type="text" value="{{ address.full_name }}">
+ id="address_full_name" name="full_name" type="text" value="{{ address.full_name }}">
@@ -100,7 +106,7 @@
focus:ring-primary-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center dark:bg-primary-600
dark:hover:bg-primary-700 dark:focus:ring-primary-800"
>
- {% translate 'Actualizar datos' %}
+ {% translate 'Guardar' %}
diff --git a/web/urls.py b/web/urls.py
index 8c210e1..f9f380f 100644
--- a/web/urls.py
+++ b/web/urls.py
@@ -9,7 +9,7 @@ from web.views.components import (
list_products,
list_wishlisted_products,
wishlist_button,
- user_info_component,
+ user_info_component, update_customer_address,
)
from web.views.users import (
login,
@@ -96,6 +96,7 @@ urlpatterns = [
delete_from_wishlist,
name="delete_from_wishlist",
),
+ path("web/customer-address/
/", update_customer_address, name="update_customer_address"),
# manifest
path("manifest.json", manifest, name="manifest_json"),
]
diff --git a/web/views/components.py b/web/views/components.py
index 6c024c5..ddbd7be 100644
--- a/web/views/components.py
+++ b/web/views/components.py
@@ -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()