from django.db import models from django.contrib.auth import get_user_model User = get_user_model() class FileType(models.TextChoices): PAY_SLIP = 'pay_slip', 'Fiche de paie' TIMETABLE = 'timetable', 'Emploi du temps' CONTRACT = 'contract', 'Contrat' IDENTITY = 'identity', 'Pièce d\'identité' OTHER = 'other', 'Autre' class File(models.Model): name = models.CharField(max_length=255) path = models.CharField(max_length=500) content = models.FileField(upload_to='files/') user = models.ForeignKey(User, on_delete=models.CASCADE, related_name='files') created_at = models.DateTimeField(auto_now_add=True) type = models.CharField(max_length=50, choices=FileType.choices) display_path = models.CharField(max_length=500, blank=True) def __str__(self): return f"{self.name} - {self.user.username}"