from django.db import models
from django.contrib.auth.models import User

class IrisUser(models.Model):
    """
    Override of the default Django User model.
    New users' fields :
        - civility
        - avatar
    """
    user = models.OneToOneField(User, on_delete=models.CASCADE)
    MALE = 'MR'
    FEMALE = 'FM'
    UNDEFINE = 'UN'
    CIVILITIES = (
        (MALE, 'Monsieur'),
        (FEMALE, 'Madame'),
        (UNDEFINE, ''),
    )
    civility = models.CharField(max_length=2, choices=CIVILITIES, default=UNDEFINE)
    avatar = models.ImageField()

    def __str__(self):
        """
        Override the new default __str__ return
        :return: The user civility
        :rtype: str
        """
        return self.user.username

class Invitation(models.Model):
    """
    Invitations send to users
    """
    user = models.OneToOneField(User)
    validation_uuid = models.CharField(max_length=50)
    send_date = models.DateTimeField('send date')
    activation_date = models.DateTimeField('activation date', blank=True, null=True)