models.py 948 B

1234567891011121314151617181920212223
  1. from django.db import models
  2. from django.contrib.auth.models import User
  3. class Azienda(models.Model):
  4. '''
  5. questa classe definisce le società che gengono gestite dal programma.
  6. ogni utente può gestire una o più società.
  7. '''
  8. nome = models.CharField(max_length=132,null=False,default="")
  9. partitaiva = models.CharField(max_length=11,null=False,default="")
  10. mail = models.CharField(max_length=256,null=False,default="")
  11. class Meta:
  12. constraints = [ models.UniqueConstraint(fields=['nome','partitaiva'], name="unique-azienda") ]
  13. indexes = [ models.Index(fields=['partitaiva','nome']) ]
  14. class Assegnazione(models.Model):
  15. '''
  16. questa tabella permette le associazioni tra società e Utente
  17. semmai, il problema è capire come associare la società all'utente registrato nella security
  18. '''
  19. azienda = models.ForeignKey(Azienda,on_delete=models.PROTECT)
  20. user = models.ForeignKey(User,on_delete=models.PROTECT)