add pk in quota activate
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
import random
|
||||
import string
|
||||
|
||||
from apps.authentication.models import Organization
|
||||
from django.contrib.postgres.fields import ArrayField
|
||||
from apps.authorization.models import UserRelations
|
||||
@@ -24,6 +27,7 @@ class ProviderCompany(BaseModel):
|
||||
|
||||
|
||||
class Device(BaseModel):
|
||||
device_identity = models.CharField(max_length=25, null=True)
|
||||
acceptor = models.IntegerField(default=0)
|
||||
terminal = models.IntegerField(default=0)
|
||||
serial = models.TextField(null=True)
|
||||
@@ -45,6 +49,15 @@ class Device(BaseModel):
|
||||
def save(self, *args, **kwargs):
|
||||
return super(Device, self).save(*args, **kwargs)
|
||||
|
||||
def generate_device_identity(self):
|
||||
""" generate identity for every device """
|
||||
prefix = "POS"
|
||||
while True:
|
||||
number_part = ''.join(random.choices(string.digits, k=6))
|
||||
code = f"{prefix}{number_part}"
|
||||
if not self.objects.filter(short_code=code).exists():
|
||||
return code
|
||||
|
||||
|
||||
class DeviceVersion(BaseModel):
|
||||
device = models.ForeignKey(
|
||||
|
||||
Reference in New Issue
Block a user