class Person(models.Model): id = PrimaryKeyUUIDField() first_name = NameField(verbose_name=_("first name")) last_name = NameField(verbose_name=_("last name")) nickname = NameField(blank=True, verbose_name=_("nickname")) date_of_birth = models.DateField(null=True, blank=True, verbose_name=_("date of birth")) date_of_death = models.DateField(null=True, blank=True, verbose_name=_("date of death")) # Email must be unique if set email = UniqueEmailField() legacy_id = models.PositiveIntegerField(null=True, blank=True) temp_tour18 = models.BooleanField(default=False) class Meta: ordering = ("first_name", "last_name") def __str__(self): return self.full_name @property def full_name(self): return (f'{self.first_name} "{self.nickname}" {self.last_name}' if self.nickname else f"{self.first_name} {self.last_name}") @property def short_name(self): return self.nickname or f"{self.first_name} {self.last_name[:1]}"
class SalePoint(models.Model): id = PrimaryKeyUUIDField() name = NameField() description = DescriptionField() def __str__(self): return self.name
class Product(models.Model): id = PrimaryKeyUUIDField() name = NameField() description = DescriptionField() price = MoneyDecimalField(null=True, blank=True) def __str__(self): return self.name
class Person(models.Model): id = PrimaryKeyUUIDField() first_name = NameField(verbose_name=_('first name')) last_name = NameField(verbose_name=_('last name')) nickname = NameField(blank=True, verbose_name=_('nickname')) date_of_birth = models.DateField( null=True, blank=True, verbose_name=_('date of birth'), ) date_of_death = models.DateField( null=True, blank=True, verbose_name=_('date of death'), ) # Email must be unique if set email = UniqueEmailField() legacy_id = models.PositiveIntegerField(null=True, blank=True) temp_tour18 = models.BooleanField(default=False) class Meta: ordering = ('first_name', 'last_name') def __str__(self): return self.full_name def save(self, *args, **kwargs): self.full_clean() super().save(*args, **kwargs) @property def full_name(self): return (f'{self.first_name} "{self.nickname}" {self.last_name}' if self.nickname else f'{self.first_name} {self.last_name}') @property def short_name(self): return self.nickname or f'{self.first_name} {self.last_name[:1]}'
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
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