annuaire-eleves/fiches/models.py
Martin Pépin 799a62798c black
2019-02-18 21:47:03 +01:00

42 lines
1.8 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")
)
full_name = models.CharField(max_length=1023, verbose_name=_("nom"))
nickname = models.CharField(max_length=1023, verbose_name=_("surnom"))
picture = models.ImageField(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(verbose_name=_("date de naissance"))
thurne = models.CharField(max_length=100, verbose_name=_("thurne"))
text_field = models.TextField(verbose_name=_("champ libre"))
printing = models.BooleanField(verbose_name=_("apparaître sur l'annuaire papier ?"))
keep_me = models.BooleanField(verbose_name=_("conserver la fiche annuaire ?"))
class Department(models.Model):
name = models.CharField(max_length=1023, verbose_name=_("nom du département"))
class Phone(models.Model):
profile = models.OneToOneField(
Profile, on_delete=models.CASCADE, verbose_name=_("profil")
)
name = models.CharField(max_length=1023, verbose_name=_("type"))
number = models.CharField(max_length=1023, verbose_name=_("numéro"))
class Social(models.Model):
profile = models.OneToOneField(
Profile, on_delete=models.CASCADE, verbose_name=_("profil")
)
name = models.CharField(max_length=1023, verbose_name=_("type"))
content = models.CharField(max_length=1023, verbose_name=_("contenu"))