device identity - device assignment - fix active quotas list bug
This commit is contained in:
@@ -46,9 +46,6 @@ class Device(BaseModel):
|
||||
def __str__(self):
|
||||
return f'Device: {self.serial} - {self.id}'
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
return super(Device, self).save(*args, **kwargs)
|
||||
|
||||
def generate_device_identity(self):
|
||||
""" generate identity for every device """
|
||||
prefix = "POS"
|
||||
@@ -58,6 +55,11 @@ class Device(BaseModel):
|
||||
if not self.objects.filter(short_code=code).exists():
|
||||
return code
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
if not self.device_identity:
|
||||
self.device_identity = self.generate_device_identity()
|
||||
return super(Device, self).save(*args, **kwargs)
|
||||
|
||||
|
||||
class DeviceVersion(BaseModel):
|
||||
device = models.ForeignKey(
|
||||
@@ -175,3 +177,30 @@ class POSClientAttributeValue(BaseModel):
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
return super(POSClientAttributeValue, self).save(*args, **kwargs)
|
||||
|
||||
|
||||
class DeviceAssignment(BaseModel):
|
||||
company = models.ForeignKey(
|
||||
ProviderCompany,
|
||||
on_delete=models.CASCADE,
|
||||
related_name='assignments',
|
||||
null=True
|
||||
)
|
||||
client = models.ForeignKey(
|
||||
POSClient,
|
||||
on_delete=models.CASCADE,
|
||||
related_name='assignment',
|
||||
null=True
|
||||
)
|
||||
device = models.ForeignKey(
|
||||
Device,
|
||||
on_delete=models.CASCADE,
|
||||
related_name='assignment',
|
||||
null=True
|
||||
)
|
||||
|
||||
def __str__(self):
|
||||
return f'Device: {self.device.serial} - Client: {self.client.name}'
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
return super(DeviceAssignment, self).save(*args, **kwargs)
|
||||
|
||||
Reference in New Issue
Block a user