Exemplo n.º 1
0
class SalePoint(models.Model):
    id = PrimaryKeyUUIDField()

    name = NameField()
    description = DescriptionField()

    def __str__(self):
        return self.name
Exemplo n.º 2
0
class Product(models.Model):
    id = PrimaryKeyUUIDField()

    name = NameField()
    description = DescriptionField()

    price = MoneyDecimalField(null=True, blank=True)

    def __str__(self):
        return self.name
Exemplo n.º 3
0
class ServiceAccount(models.Model):
    id = PrimaryKeyUUIDField()

    token = models.CharField(max_length=AUTH_TOKEN_LENGTH, editable=False)

    name = NameField()
    description = DescriptionField()

    def save(self, *args, **kwargs):
        if not self.token:
            self.token = hex_string(length=AUTH_TOKEN_LENGTH)
        super().save(*args, **kwargs)

    @property
    def is_anonymous(self):
        return False

    @property
    def is_authenticated(self):
        return True
Exemplo n.º 4
0
class Role(MPTTModel, models.Model):
    id = PrimaryKeyUUIDField()

    name = NameField()
    description = DescriptionField()

    parent = TreeForeignKey("self",
                            on_delete=models.CASCADE,
                            related_name="children",
                            null=True,
                            blank=True)

    membership = models.BooleanField(default=False)
    engagement = models.BooleanField(default=False)

    legacy_table = models.CharField(max_length=64, blank=True)
    legacy_id = models.CharField(max_length=64, blank=True)

    class MPTTMeta:
        order_insertion_by = ["name"]

    def __str__(self):
        return self.name