feat: reset migrations and created customer address model

This commit is contained in:
2024-12-07 10:10:14 +01:00
parent 1ffa5b117f
commit 48d39f55ba
18 changed files with 863 additions and 908 deletions
+45 -3
View File
@@ -1,6 +1,7 @@
from decimal import Decimal
from uuid import uuid4
from django.conf import settings
from django.contrib.auth import get_user_model
from django.db import models
from django.utils import timezone
@@ -346,9 +347,8 @@ class Order(TimestampedModel):
default=Decimal("0"), max_digits=13, decimal_places=2, verbose_name=_("total")
)
# Customer reference
customer = models.ForeignKey(
"shop.Customer", on_delete=models.PROTECT, verbose_name=_("cliente")
user = models.ForeignKey(
User, on_delete=models.PROTECT, verbose_name=_("cliente")
)
# Billing information
@@ -436,3 +436,45 @@ class CartItem(models.Model):
class Meta:
verbose_name = _("línea de carrito")
verbose_name_plural = _("líneas de carrito")
class CustomerAddress(models.Model):
class Types(models.TextChoices):
BILLING = "BILL", _("facturación")
SHIPPING = "SHIP", _("envío")
user = models.ForeignKey(User, on_delete=models.CASCADE, verbose_name=_("usuario"))
vat_id = models.CharField(
max_length=16,
blank=True,
null=True,
default="",
verbose_name=_("número de identificación fiscal"),
)
address = models.CharField(
max_length=128, blank=False, null=False, verbose_name=_("dirección")
)
address_town = models.CharField(
max_length=64, blank=False, null=False, verbose_name=_("localidad")
)
address_zip = models.CharField(
max_length=16, blank=False, null=False, verbose_name=_("código postal")
)
address_state = models.CharField(
max_length=64, blank=False, null=False, verbose_name=_("provincia")
)
address_country = models.CharField(
max_length=64, default=settings.SHOP_COUNTRY, blank=False, null=False, verbose_name=_("país")
)
address_phone = models.CharField(
max_length=16, blank=True, null=True, default="", verbose_name=_("teléfono")
)
address_type = models.CharField(
max_length=4, choices=Types.choices, default=Types.SHIPPING, verbose_name=_("tipo de dirección")
)
default = models.BooleanField(default=True)
class Meta:
verbose_name = _("dirección de cliente")
verbose_name_plural = _("direcciones de cliente")