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


LANGUAGE_CHOICES = [
    ('en', 'English'),
    ('fr', 'Français'),
    ('de', 'Deutsch'),
    ('es', 'Español'),
]


class User(AbstractUser):
    """
    Custom user model — kept intentionally thin so the schema can evolve.
    Authentication is handled by dj-rest-auth + allauth (JWT + external IDP).
    """
    email = models.EmailField(unique=True)
    avatar = models.ForeignKey(
        'photos.Photo',
        null=True, blank=True,
        on_delete=models.SET_NULL,
        related_name='avatar_user',
    )
    language = models.CharField(max_length=5, choices=LANGUAGE_CHOICES, default='en', verbose_name='language')

    USERNAME_FIELD = 'email'
    REQUIRED_FIELDS = ['username']

    def __str__(self):
        return self.email
