mirror of
https://github.com/omaha-consulting/winget.pro.git
synced 2026-10-24 12:52:26 +00:00
18 lines
596 B
Python
18 lines
596 B
Python
from django.contrib.auth.models import User
|
|
from django.core.exceptions import ObjectDoesNotExist
|
|
from django.db.models import Model, UUIDField, ManyToManyField
|
|
from uuid import uuid4
|
|
|
|
class Tenant(Model):
|
|
|
|
users = ManyToManyField(User)
|
|
uuid = UUIDField(unique=True, default=uuid4, editable=False)
|
|
|
|
def __str__(self):
|
|
# We have to check that `id` is set to avoid a `RecursionError`.
|
|
if self.id:
|
|
try:
|
|
return self.users.earliest('date_joined').username
|
|
except ObjectDoesNotExist:
|
|
pass
|
|
return str(self.uuid) |