debug and migrations order
This commit is contained in:
+17
-14
@@ -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
|
||||
Reference in New Issue
Block a user