models.py 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. from django.db import models
  2. from django.utils import timezone
  3. class Amministratore(models.Model):
  4. login = models.CharField(max_length=64,null=False)
  5. nome = models.CharField(max_length=128,null=False,unique=True)
  6. mail = models.CharField(max_length=128,null=False,default="")
  7. pin = models.CharField(max_length=64,null=False)
  8. '''
  9. uuid = models.CharField(max_length=32,null=False,default="")
  10. sola_lettura = models.BooleanField(default=False)
  11. crea_azienda = models.BooleanField(default=True)
  12. crea_sede = models.BooleanField(default=True)
  13. crea_utente = models.BooleanField(default=True)
  14. crea_documento = models.BooleanField(default=True)
  15. crea_comunicazione = models.BooleanField(default=True)
  16. edit_azienda = models.BooleanField(default=True)
  17. edit_sede = models.BooleanField(default=True)
  18. edit_utente = models.BooleanField(default=True)
  19. edit_documento = models.BooleanField(default=True)
  20. edit_comunicazione = models.BooleanField(default=True)
  21. crea_permesso = models.BooleanField(default=False)
  22. edit_permesso = models.BooleanField(default=False)
  23. read_permesso = models.BooleanField(default=True)
  24. '''
  25. def __str__(self):
  26. return f"{self.id}: {self.nome}"
  27. class Permesso(models.Model):
  28. nome=models.CharField(null=True,max_length=20)
  29. descrizione=models.CharField(null=True,max_length=128)
  30. def __str__(self):
  31. return f"{self.id}: {self.nome}"
  32. class AP(models.Model):
  33. # AP: Associazione Permessi
  34. amministratore = models.ForeignKey(Amministratore,on_delete=models.PROTECT)
  35. permesso = models.ForeignKey(Permesso,on_delete=models.PROTECT)