91 lines
3.1 KiB
Python
91 lines
3.1 KiB
Python
from django.db import models
|
|
from django.core.validators import MinValueValidator
|
|
from django.utils.translation import ugettext_lazy as _
|
|
from django.contrib.auth.models import User
|
|
|
|
|
|
class Profile(models.Model):
|
|
user = models.OneToOneField(
|
|
User,
|
|
on_delete=models.CASCADE,
|
|
verbose_name=_("utilisateur"),
|
|
related_name="profile",
|
|
)
|
|
full_name = models.CharField(max_length=1023, verbose_name=_("nom"))
|
|
nickname = models.CharField(blank=True, max_length=1023, verbose_name=_("surnom"))
|
|
pronoun = models.CharField(
|
|
blank=True, max_length=1023, verbose_name=_("pronom(s) utilisé(s)")
|
|
)
|
|
picture = models.ImageField(
|
|
blank=True, upload_to="picture", verbose_name=_("photo")
|
|
)
|
|
department = models.ManyToManyField("Department", verbose_name=_("département"))
|
|
promotion = models.IntegerField(
|
|
validators=[MinValueValidator(1980)], verbose_name=_("promotion")
|
|
)
|
|
birth_date = models.DateField(blank=True, verbose_name=_("date de naissance"))
|
|
thurne = models.CharField(blank=True, max_length=100, verbose_name=_("thurne"))
|
|
text_field = models.TextField(blank=True, verbose_name=_("champ libre"))
|
|
printing = models.BooleanField(
|
|
default=False, verbose_name=_("apparaître sur l'annuaire papier ?")
|
|
)
|
|
keep_me = models.BooleanField(
|
|
default=False, verbose_name=_("conserver la fiche annuaire ?")
|
|
)
|
|
|
|
def __str__(self):
|
|
return self.full_name
|
|
|
|
def birthday(self):
|
|
return self.birth_date.strftime("%d%m")
|
|
|
|
|
|
class Department(models.Model):
|
|
name = models.CharField(max_length=255, verbose_name=_("nom du département"))
|
|
|
|
def __str__(self):
|
|
return self.name
|
|
|
|
|
|
class Phone(models.Model):
|
|
profile = models.ForeignKey(
|
|
Profile, on_delete=models.CASCADE, verbose_name=_("profil")
|
|
)
|
|
name = models.CharField(max_length=255, verbose_name=_("type"))
|
|
number = models.CharField(max_length=1023, verbose_name=_("numéro"))
|
|
|
|
def __str__(self):
|
|
return "{} : {}".format(self.name, self.number)
|
|
|
|
|
|
class Social(models.Model):
|
|
profile = models.ForeignKey(
|
|
Profile, on_delete=models.CASCADE, verbose_name=_("profil")
|
|
)
|
|
name = models.CharField(max_length=255, verbose_name=_("type"))
|
|
content = models.CharField(max_length=1023, verbose_name=_("contenu"))
|
|
|
|
def __str__(self):
|
|
return "{} : {}".format(self.name, self.content)
|
|
|
|
|
|
class Mail(models.Model):
|
|
profile = models.ForeignKey(
|
|
Profile, on_delete=models.CASCADE, verbose_name=_("profil")
|
|
)
|
|
name = models.CharField(max_length=255, verbose_name=_("type"))
|
|
mail = models.CharField(max_length=1023, verbose_name=_("adresse mail"))
|
|
|
|
def __str__(self):
|
|
return "{} : {}".format(self.name, self.mail)
|
|
|
|
|
|
class Address(models.Model):
|
|
profile = models.ForeignKey(
|
|
Profile, on_delete=models.CASCADE, verbose_name=_("profil")
|
|
)
|
|
name = models.CharField(max_length=255, verbose_name=_("type"))
|
|
content = models.CharField(max_length=1023, verbose_name=_("adresse"))
|
|
|
|
def __str__(self):
|
|
return "{} : {}".format(self.name, self.content)
|