first commit
This commit is contained in:
commit
3e4574dcdd
163 files changed
+3559
No files matched your search
@@ -0,0 +1,40 @@
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.db import models
|
||||
from utils.base_model import BaseModel
|
||||
from apps.product.models import Product as ProductModel
|
||||
# Create your models here.
|
||||
CUserModel = get_user_model()
|
||||
|
||||
|
||||
class Order(BaseModel):
|
||||
|
||||
STATUS_CHOICES = (
|
||||
('waiting', 'در انتظار برسی'),
|
||||
('approve', 'تایید شد'),
|
||||
('canceled', 'رد شده'),
|
||||
)
|
||||
product = models.ForeignKey(ProductModel, on_delete=models.SET_NULL, null=True, blank=True)
|
||||
name = models.CharField(max_length=30, null=False, blank=False)
|
||||
desc = models.CharField(max_length=30, null=True, blank=True)
|
||||
code = models.TextField(null=True, blank=True)
|
||||
price = models.PositiveIntegerField(null=True, blank=True)
|
||||
emtiyaz = models.PositiveIntegerField(null=False, blank=False)
|
||||
status = models.CharField(max_length=30, choices=STATUS_CHOICES, default='waiting')
|
||||
cuser_mojri = models.ForeignKey(CUserModel, on_delete=models.SET_NULL, null=True, blank=True)
|
||||
|
||||
def __str__(self):
|
||||
cuser_name = getattr(self.cuser_mojri, 'name_family', None)
|
||||
cuser_username = getattr(self.cuser_mojri, 'username', None)
|
||||
product_name = getattr(self.product, 'name', None)
|
||||
|
||||
if cuser_name and product_name:
|
||||
return f'{cuser_name} - {product_name} - {cuser_username}'
|
||||
elif cuser_name:
|
||||
return f'{ cuser_name } - {cuser_username}'
|
||||
elif product_name:
|
||||
return f'{product_name} - {cuser_username}'
|
||||
|
||||
|
||||
class Meta:
|
||||
ordering = ['-created_at']
|
||||
|
||||
Reference in new issue
Block a user