fix organization limit quota seialize

This commit is contained in:
2025-07-21 12:35:24 +03:30
parent df0b8edb98
commit 0f4d051380
5 changed files with 244 additions and 11 deletions

View File

@@ -1,8 +1,9 @@
from django.db import models
from apps.core.models import BaseModel
from apps.authentication.models import Organization
class PaymentCompany(BaseModel):
class ProviderCompany(BaseModel):
name_fa = models.CharField(max_length=250, null=True)
name_en = models.CharField(max_length=250, null=True)
activation = models.BooleanField(default=False)
@@ -11,7 +12,7 @@ class PaymentCompany(BaseModel):
return f'Payment Company: {self.name_fa}-{self.id}'
def save(self, *args, **kwargs):
return super(PaymentCompany, self).save(*args, **kwargs)
return super(ProviderCompany, self).save(*args, **kwargs)
class Device(BaseModel):
@@ -24,7 +25,7 @@ class Device(BaseModel):
latitude = models.DecimalField(max_digits=20, decimal_places=10, null=True)
longitude = models.DecimalField(max_digits=20, decimal_places=10, null=True)
company = models.ForeignKey(
PaymentCompany,
ProviderCompany,
on_delete=models.CASCADE,
related_name='devices',
null=True
@@ -41,13 +42,13 @@ class DeviceVersion(BaseModel):
device = models.ForeignKey(
Device,
on_delete=models.CASCADE,
related_name='devices',
related_name='devices_version',
null=True
)
company = models.ForeignKey(
PaymentCompany,
ProviderCompany,
on_delete=models.CASCADE,
related_name='devices',
related_name='devices_company',
null=True
)
name = models.CharField(max_length=250, null=True)
@@ -55,10 +56,10 @@ class DeviceVersion(BaseModel):
description = models.TextField(null=True)
enable = models.BooleanField(default=True)
remove = models.BooleanField(default=False)
def __str__(self):
return f'Version: {self.name}-{self.device.serial}'
def save(self, *args, **kwargs):
return super(DeviceVersion, self).save(*args, **kwargs)
@@ -79,9 +80,35 @@ class Sessions(BaseModel):
serial = models.TextField(null=True)
latitude = models.DecimalField(max_digits=20, decimal_places=10, null=True)
longitude = models.DecimalField(max_digits=20, decimal_places=10, null=True)
def __str__(self):
return f'Session: {self.name}-{self.version}-{self.id}'
def save(self, *args, **kwargs):
return super(Sessions, self).save(*args, **kwargs)
class POSClient(BaseModel):
name = models.CharField(max_length=255, null=True)
client_type = models.CharField(max_length=25, choices=[
('business', 'صنف'),
('person', 'شخص آزاد'), # noqa
('organization', 'سازمان') # noqa
])
is_organization = models.BooleanField(default=False)
organization = models.OneToOneField(
Organization,
on_delete=models.CASCADE,
related_name='client',
null=True
)
def __str__(self):
return f'POSClient: {self.name}-{self.id}'
def save(self, *args, **kwargs):
return super(POSClient, self).save(*args, **kwargs)
class POSClientAttribute(BaseModel):
pass