from django.db import models
import datetime
from utente.models import *
from comunicazione.models import *

class Documento(models.Model):
  utente = models.ForeignKey(Utente,on_delete=models.CASCADE)
  documento = models.CharField(max_length=256,null=True,default="")
  storage = models.CharField(max_length=256,null=True,default="")
  dataupload = models.DateField(null=True,default=datetime.date.today)
  crc = models.CharField(max_length=256,null=False,default="")
  descrizione = models.CharField(max_length=128,null=False,default="")

  def __str__(self):
    return f"{self.id}: {self.documento}"
 
  class Meta:
    constraints = [ models.UniqueConstraint(fields=['documento'], name="unique-documento") ]
    #indexes = [ models.Index(fields=['documento','utente']) ]


