debug and migrations order

This commit is contained in:
Parsa Nazer
2025-01-26 03:17:57 +03:30
parent da1bdc2886
commit 7ffd128e2d
2 changed files with 79 additions and 14 deletions
+17 -14
View File
@@ -3,6 +3,23 @@ from account.models import User, UserAddressModel
from product.models import ProductModel
from django.utils import timezone
class DiscountCode(models.Model):
name = models.CharField(max_length=50)
percent = models.DecimalField(max_digits=4, decimal_places=2)
quantity = models.PositiveIntegerField()
expiration_date = models.DateTimeField()
def __str__(self):
return self.name
class Meta:
verbose_name = 'کد تخفیف'
verbose_name_plural = 'کد های تخفیف'
def is_valid(self):
return self.expiration_date > timezone.now() and self.quantity > 0
class OrderModel(models.Model):
STATUS_CHOICES = [
('CART', 'در سبد خرید'),
@@ -70,17 +87,3 @@ class OrderItemModel(models.Model):
return self.quantity * self.product.get_toman_price_after_discount()
class DiscountCode(models.Model):
name = models.CharField(max_length=50)
percent = models.DecimalField(max_digits=4, decimal_places=2)
quantity = models.PositiveIntegerField()
expiration_date = models.DateTimeField()
def __str__(self):
return self.name
class Meta:
verbose_name = 'کد تخفیف'
verbose_name_plural = 'کد های تخفیف'
def is_valid(self):
return self.expiration_date > timezone.now() and self.quantity > 0