from sicurezza.models import *
from django.db.utils import IntegrityError 

for a in Amministratore.objects.all():
    for p in Permesso.objects.all():
        print(a.nome,p.nome)
        amp = AMP()
        amp.amministratore = a
        amp.permesso = p
        try:
          amp.save()
        except IntegrityError as ie:
          print('presente')

for a in Amministratore.objects.all():
    for z in Azienda.objects.all():
        for p in Permesso.objects.all():
            print(a.nome,z.nome,p.nome)
            azp = AZP()
            azp.amministratore = a
            azp.azienda = z
            azp.permesso = p
            try:
                azp.save()
            except IntegrityError as ie:
                print('presente')

for a in Amministratore.objects.all():
    for z in Sede.objects.all():
        for p in Permesso.objects.all():
            print(a.nome,z.nome,p.nome)
            azp = SEP()
            azp.amministratore = a
            azp.sede = z
            azp.permesso = p
            try:
                azp.save()
            except IntegrityError as ie:
                print('presente')

