|
|
@@ -12,11 +12,16 @@ def welcome(request):
|
|
|
if not 'AdminId' in request.session:
|
|
|
return HttpResponseRedirect(reverse("login:start"))
|
|
|
|
|
|
+ data = dict()
|
|
|
+ data['HeaderTitle'] = getConfig('HeaderTitle')
|
|
|
+ data['Navbar']=True
|
|
|
+
|
|
|
AdminId = request.session['AdminId']
|
|
|
print('AdminId',AdminId)
|
|
|
+ admin = Amministratore.objects.get(pk=AdminId)
|
|
|
+ data['admin'] = admin
|
|
|
+ print('admin',admin.id,admin.nome)
|
|
|
|
|
|
- data = dict()
|
|
|
-
|
|
|
azienda = None
|
|
|
if 'AziendaId' in request.session:
|
|
|
AziendaId = request.session['AziendaId']
|
|
|
@@ -31,15 +36,9 @@ def welcome(request):
|
|
|
try:
|
|
|
sede = Sede.objects.get(pk=SedeId)
|
|
|
except Sede.DoesNotExist as dne:
|
|
|
- print("non esiste")
|
|
|
+ print("Sede non esiste")
|
|
|
data['sede'] = sede
|
|
|
-
|
|
|
- data['HeaderTitle'] = getConfig('HeaderTitle')
|
|
|
- data['Navbar']=True
|
|
|
- admin = Amministratore.objects.get(pk=AdminId)
|
|
|
- data['admin'] = admin
|
|
|
- print('admin',admin.id,admin.nome)
|
|
|
-
|
|
|
+
|
|
|
### permessi inizio ###
|
|
|
data['permesso'] = getAMP(admin)[0]
|
|
|
if 'AziendaId' in data:
|
|
|
@@ -54,7 +53,7 @@ def welcome(request):
|
|
|
print('permesso_azienda',getAZP(data['AziendaId'],admin))
|
|
|
print('permesso_sede',getSEP(data['sede'],admin))
|
|
|
### permessi fine ###
|
|
|
-
|
|
|
+
|
|
|
### ricerca delle aziende valide per questo amministratore
|
|
|
assegnazioneazienda = listaAZP(admin)[0]
|
|
|
print('assegnazioneazienda',len(assegnazioneazienda))
|
|
|
@@ -66,11 +65,13 @@ def welcome(request):
|
|
|
request.session['AziendaId'] = azienda.id
|
|
|
print("Singola Azienda",azienda.nome)
|
|
|
|
|
|
+ ### lista delle sedi valida per questo amministratore
|
|
|
assegnazionesede=None
|
|
|
if azienda:
|
|
|
assegnazionesede = listaSEP(admin,azienda)
|
|
|
print("assegnazionesede",len(assegnazionesede))
|
|
|
|
|
|
+ ### lista attività ###
|
|
|
data['listaAttivitaxAmministrazione']=getLogxAmministrazione(admin)
|
|
|
|
|
|
if request.method=="POST":
|
|
|
@@ -92,7 +93,16 @@ def welcome(request):
|
|
|
# attività su nuova/edit azienda
|
|
|
if sceltaazienda == -1: #richiesta una nuova azienda
|
|
|
print('sceltaazienda -1:',sceltaazienda)
|
|
|
- #return HttpResponseRedirect(reverse('azienda:editAzienda'))
|
|
|
+ if "AziendaId" in request.session:
|
|
|
+ del request.session['AziendaId']
|
|
|
+ if "azienda" in request.session:
|
|
|
+ del request.session['azienda']
|
|
|
+ if "SedeId" in request.session:
|
|
|
+ del request.session['SedeId']
|
|
|
+ if "sede" in request.session:
|
|
|
+ del request.session['sede']
|
|
|
+ return HttpResponseRedirect(reverse('azienda:welcome'))
|
|
|
+
|
|
|
elif sceltaazienda == 0:
|
|
|
print('sceltaazienda 0:',sceltaazienda)
|
|
|
request.session['AziendaIdEdit'] = 0
|
|
|
@@ -180,11 +190,18 @@ def welcome(request):
|
|
|
|
|
|
if 'azienda' in data:
|
|
|
print('azienda selezionata:',data['azienda'].nome)
|
|
|
- data['SedeLista'] = data['azienda'].sede_set.all().order_by('nome')
|
|
|
-
|
|
|
+ # costruisce la lista delle sedi.
|
|
|
+ #data['SedeLista'] = data['azienda'].sede_set.all().order_by('nome')
|
|
|
+ print(":::",listaSEP(data['azienda'],admin))
|
|
|
+ data['SedeLista'] = listaSEP(data['azienda'],admin)[0]
|
|
|
+ print("::::",data['SedeLista'])
|
|
|
+ print(data)
|
|
|
+
|
|
|
print('numero aziende',len(data['AziendaLista']))
|
|
|
+
|
|
|
if 'SedeLista' in data:
|
|
|
print('numero di sedi',len(data['SedeLista']))
|
|
|
+ for i in data['SedeLista']: print(":::",i.nome)
|
|
|
|
|
|
return render(request,'azienda.welcome.html',data)
|
|
|
|
|
|
@@ -194,10 +211,15 @@ def editAzienda(request):
|
|
|
if not 'AdminId' in request.session:
|
|
|
return HttpResponseRedirect(reverse("login:start"))
|
|
|
|
|
|
+ data=dict()
|
|
|
+ data['HeaderTitle'] = getConfig('HeaderTitle')
|
|
|
+ data['Navbar']=False
|
|
|
+
|
|
|
AdminId = request.session['AdminId']
|
|
|
print('AdminId',AdminId)
|
|
|
-
|
|
|
- data=dict()
|
|
|
+ admin = Amministratore.objects.get(pk=AdminId)
|
|
|
+ data['admin'] = admin
|
|
|
+ print('admin',admin.id,admin.nome)
|
|
|
|
|
|
azienda = None
|
|
|
if 'AziendaId' in request.session:
|
|
|
@@ -213,13 +235,10 @@ def editAzienda(request):
|
|
|
try:
|
|
|
sede = Sede.objects.get(pk=SedeId)
|
|
|
except Sede.DoesNotExist as dne:
|
|
|
- print("non esiste")
|
|
|
+ print("Sede non esiste")
|
|
|
data['sede'] = sede
|
|
|
|
|
|
- data['HeaderTitle'] = getConfig('HeaderTitle')
|
|
|
- data['Navbar']=False
|
|
|
- user = data['admin'] = Amministratore.objects.get(pk=AdminId)
|
|
|
-
|
|
|
+ ### azienda su cui effettuare le operazioni
|
|
|
azienda = None
|
|
|
if 'AziendaIdEdit' in request.session:
|
|
|
print('trovato riferimento AziendaIdEdit',request.session.get('AziendaIdEdit'))
|
|
|
@@ -228,113 +247,148 @@ def editAzienda(request):
|
|
|
azienda = Azienda.objects.get(pk=azid)
|
|
|
print('azienda trovata',azienda.nome)
|
|
|
except Azienda.DoesNotExist as dnf:
|
|
|
- print(dnf)
|
|
|
-
|
|
|
- data['permesso_amministratore'] = getAMP(AdminId)[0]
|
|
|
- data['permesso_azienda'] = getAZP(azienda,AdminId)
|
|
|
-
|
|
|
- print('permesso_amministratore',data['permesso_amministratore'])
|
|
|
- print('permesso_azienda',data['permesso_azienda'])
|
|
|
-
|
|
|
- if 'indietro' in request.POST:
|
|
|
- return HttpResponseRedirect(reverse('azienda:welcome'))
|
|
|
-
|
|
|
- if request.method == "POST":
|
|
|
- print("Richiesta creazione nuova azienda")
|
|
|
- nuovaazienda = formAzienda(request.POST)
|
|
|
- if nuovaazienda.is_valid():
|
|
|
- print("il form e' valido",request.POST)
|
|
|
- if not azienda:
|
|
|
- azienda = Azienda()
|
|
|
- setAZP(azienda,data['admin'],"AZIENDA")
|
|
|
- if 'AZIENDA.CREA' in getAMP(data['admin'])[0]:
|
|
|
- setAZP(azienda,data['admin'],"AZIENDA.CREA")
|
|
|
- if 'AZIENDA.EDIT' in getAMP(data['admin'])[0]:
|
|
|
- setAZP(azienda,data['admin'],"AZIENDA.EDIT")
|
|
|
- if 'UTENTE' in getAMP(data['admin'])[0]:
|
|
|
- setAZP(azienda,data['admin'],"UTENTE")
|
|
|
- if 'UTENTE.CREA' in getAMP(data['admin'])[0]:
|
|
|
- setAZP(azienda,data['admin'],"UTENTE.CREA")
|
|
|
-
|
|
|
- azienda.nome = nuovaazienda.cleaned_data.get('nome')
|
|
|
- azienda.mail = nuovaazienda.cleaned_data.get('mail')
|
|
|
- azienda.partitaiva = nuovaazienda.cleaned_data.get('partitaiva')
|
|
|
- azienda.cambiopassword = nuovaazienda.cleaned_data.get('cambiopassword')
|
|
|
- azienda.forzanuovapassword = nuovaazienda.cleaned_data.get('forzanuovapassword')
|
|
|
- azienda.save()
|
|
|
- request.session['AziendaIdEdit'] = azienda.id
|
|
|
- print('azienda:',azienda.id)
|
|
|
-
|
|
|
- #assegnazione = AssegnazioneAzienda()
|
|
|
- #assegnazione.azienda=azienda
|
|
|
- #assegnazione.amministratore=Amministratore.objects.get(pk=AdminId)
|
|
|
- #assegnazione.save()
|
|
|
+ print(dnf)
|
|
|
+ azienda = Azienda()
|
|
|
+
|
|
|
+ #### permessi ####
|
|
|
+ data['permesso'] = getAMP(admin)[0]
|
|
|
+ for t in getAZP(azienda,admin):
|
|
|
+ if t not in data['permesso']:
|
|
|
+ data['permesso'].append(t)
|
|
|
+ for t in getSEP(data['sede'],admin):
|
|
|
+ if t not in data['permesso']:
|
|
|
+ data['permesso'].append(t)
|
|
|
+ print('permessi:',data['permesso'])
|
|
|
+ #### permessi ####
|
|
|
+
|
|
|
+ if request.method == 'POST':
|
|
|
+ print('un tasto è stato premuto')
|
|
|
|
|
|
- del request.session['AziendaIdEdit']
|
|
|
+ if 'indietro' in request.POST:
|
|
|
return HttpResponseRedirect(reverse('azienda:welcome'))
|
|
|
- else:
|
|
|
- print("form non valido")
|
|
|
- data['aziendaForm'] = formAzienda(request.POST)
|
|
|
- else: #non è un post
|
|
|
- print("Non è un post")
|
|
|
- formAziendaField = None
|
|
|
-
|
|
|
- if azienda:
|
|
|
- print('Abbiamo azienda',azienda.nome)
|
|
|
- tmp = dict()
|
|
|
- tmp['id'] = azienda.id
|
|
|
- tmp['nome'] = azienda.nome
|
|
|
- tmp['partitaiva'] = azienda.partitaiva
|
|
|
- tmp['mail'] = azienda.mail
|
|
|
- tmp['forzanuovapassword'] = azienda.forzanuovapassword
|
|
|
- tmp['cambiopassword'] = azienda.cambiopassword
|
|
|
- formAziendaField = formAzienda(tmp)
|
|
|
- else:
|
|
|
- tmp = dict()
|
|
|
- tmp['nome'] = ''
|
|
|
- tmp['partitaiva'] = ''
|
|
|
- tmp['mail'] = user.mail
|
|
|
- tmp['forzanuovapassword'] = False
|
|
|
- tmp['cambiopassword' ] = False
|
|
|
- formAziendaField = formAzienda(tmp)
|
|
|
-
|
|
|
- data['aziendaForm'] = formAziendaField
|
|
|
- data['listaAmministratore'],oggetti = listaAMMperAzienda(AziendaId)
|
|
|
- print(data['listaAmministratore'])
|
|
|
+
|
|
|
+ if 'AggiornaAziendaButton' in request.POST:
|
|
|
+ print('premuto tasto "AggiornaAziendaButton"')
|
|
|
+ nuovaazienda = formAzienda(request.POST)
|
|
|
+ if nuovaazienda.is_valid():
|
|
|
+ print("il form e' valido",request.POST)
|
|
|
+
|
|
|
+
|
|
|
+ azienda.nome = nuovaazienda.cleaned_data.get('nome')
|
|
|
+ azienda.mail = nuovaazienda.cleaned_data.get('mail')
|
|
|
+ azienda.partitaiva = nuovaazienda.cleaned_data.get('partitaiva')
|
|
|
+ azienda.cambiopassword = nuovaazienda.cleaned_data.get('cambiopassword')
|
|
|
+ azienda.forzanuovapassword = nuovaazienda.cleaned_data.get('forzanuovapassword')
|
|
|
+ azienda.otppassword = nuovaazienda.cleaned_data.get('otppassword')
|
|
|
+ azienda.save()
|
|
|
+
|
|
|
+ request.session['AziendaIdEdit'] = azienda.id
|
|
|
+ print('azienda:',azienda.id)
|
|
|
+
|
|
|
+ ### nel caso l'azienda non esista, si aggiungono i permessi di base
|
|
|
+ if not azienda:
|
|
|
+ setAZP(azienda,data['admin'],"AZIENDA")
|
|
|
+ if 'AZIENDA.CREA' in getAMP(data['admin'])[0]:
|
|
|
+ setAZP(azienda,data['admin'],"AZIENDA.CREA")
|
|
|
+ if 'AZIENDA.EDIT' in getAMP(data['admin'])[0]:
|
|
|
+ setAZP(azienda,data['admin'],"AZIENDA.EDIT")
|
|
|
+ if 'UTENTE' in getAMP(data['admin'])[0]:
|
|
|
+ setAZP(azienda,data['admin'],"UTENTE")
|
|
|
+ if 'UTENTE.CREA' in getAMP(data['admin'])[0]:
|
|
|
+ setAZP(azienda,data['admin'],"UTENTE.CREA")
|
|
|
+ else:
|
|
|
+ data['aziendaForm'] = formAzienda(request.POST)
|
|
|
+
|
|
|
+ if 'CancellaAziendaPermessiButton' in request.POST:
|
|
|
+ print('premuto "CancellaAziendaPermessiButton"')
|
|
|
+ cancellaaziendaamministratoripermessi = request.POST.get('CancellaAziendaPermessiButton')
|
|
|
+ print('CancellaAziendaAmministratoriPermessi',cancellaaziendaamministratoripermessi)
|
|
|
+ azp = AZP.objects.get(pk=cancellaaziendaamministratoripermessi)
|
|
|
+ if azp:
|
|
|
+ print('Permesso Azienda Amministratore trovato - cancello')
|
|
|
+ azp.delete()
|
|
|
+
|
|
|
+ if 'PermessoDaAggiungereButton' in request.POST:
|
|
|
+ print('premuto "PermessoDaAggiungereButton"')
|
|
|
+ formaziendapermessi = formAziendaPermessi(request.POST,amministratori=Amministratore.objects.all())
|
|
|
+ #formaziendapermessi.c(Amministratore.objects.all()) # alternativa: lista dei soli amministratori con autorizzazione AZIENDA in AMM
|
|
|
+ #print(formaziendapermessi)
|
|
|
+ if formaziendapermessi.is_valid():
|
|
|
+ print('formAziendaPermessi valida')
|
|
|
+ amministratori = formaziendapermessi.cleaned_data.get('ListaAmministratoriPermessi')
|
|
|
+ print('amministratori da aggiungere',amministratori)
|
|
|
+ for x in amministratori:
|
|
|
+ print('am',amministratori,'az',azienda.nome)
|
|
|
+ try:
|
|
|
+ setAZP(azienda,str(x),"AZIENDA")
|
|
|
+ except ValueError as ve:
|
|
|
+ print('errore in SETAZP')
|
|
|
+ else:
|
|
|
+ print('formAziendaPermessi Errore')
|
|
|
+ print(formaziendapermessi)
|
|
|
+
|
|
|
+ formaziendafield = None
|
|
|
+ if azienda:
|
|
|
+ print('Abbiamo azienda',azienda.nome)
|
|
|
+ tmp = dict()
|
|
|
+ tmp['id'] = azienda.id
|
|
|
+ tmp['nome'] = azienda.nome
|
|
|
+ tmp['partitaiva'] = azienda.partitaiva
|
|
|
+ tmp['mail'] = azienda.mail
|
|
|
+ tmp['forzanuovapassword'] = azienda.forzanuovapassword
|
|
|
+ tmp['cambiopassword'] = azienda.cambiopassword
|
|
|
+ tmp['otppassword'] = azienda.otppassword
|
|
|
+ formaziendafield = formAzienda(tmp)
|
|
|
+ else:
|
|
|
+ tmp = dict()
|
|
|
+ tmp['nome'] = ''
|
|
|
+ tmp['partitaiva'] = ''
|
|
|
+ tmp['mail'] = user.mail
|
|
|
+ tmp['forzanuovapassword'] = False
|
|
|
+ tmp['cambiopassword' ] = False
|
|
|
+ tmp['otppassword'] = False
|
|
|
+ formaziendafield = formAzienda(tmp)
|
|
|
+ data['aziendaForm'] = formaziendafield
|
|
|
+
|
|
|
+ data['listaAmministratore'] = listaAMMperAzienda(AziendaId)[1]
|
|
|
+ print(data['listaAmministratore'])
|
|
|
+ data['listaAmministratoreDaAggiungere'] = Amministratore.objects.all()
|
|
|
|
|
|
return render(request,'azienda.editAzienda.html',data)
|
|
|
|
|
|
def editSede(request):
|
|
|
- ''' edit Sedi azienda '''
|
|
|
+
|
|
|
if not 'AdminId' in request.session:
|
|
|
return HttpResponseRedirect(reverse("login:start"))
|
|
|
|
|
|
+ data=dict()
|
|
|
+ data['HeaderTitle'] = getConfig('HeaderTitle')
|
|
|
+ data['Navbar']=False
|
|
|
+
|
|
|
AdminId = request.session['AdminId']
|
|
|
print('AdminId',AdminId)
|
|
|
+ admin = Amministratore.objects.get(pk=AdminId)
|
|
|
+ data['admin'] = admin
|
|
|
+ print('admin',admin.id,admin.nome)
|
|
|
|
|
|
- data = dict()
|
|
|
-
|
|
|
+ azienda = None
|
|
|
if 'AziendaId' in request.session:
|
|
|
AziendaId = request.session['AziendaId']
|
|
|
print('AziendaId',AziendaId)
|
|
|
- data['azienda'] = Azienda.objects.get(pk=AziendaId)
|
|
|
-
|
|
|
+ azienda = Azienda.objects.get(pk=AziendaId)
|
|
|
+ data['azienda'] = azienda
|
|
|
+
|
|
|
+ sede = None
|
|
|
if 'SedeId' in request.session:
|
|
|
SedeId = request.session['SedeId']
|
|
|
print('SedeId',SedeId)
|
|
|
try:
|
|
|
- data['sede'] = Sede.objects.get(pk=SedeId)
|
|
|
+ sede = Sede.objects.get(pk=SedeId)
|
|
|
except Sede.DoesNotExist as dne:
|
|
|
- print("non esiste")
|
|
|
-
|
|
|
- data['HeaderTitle'] = getConfig('HeaderTitle')
|
|
|
- data['Navbar']=False
|
|
|
-
|
|
|
- data['HeaderTitle'] = getConfig('HeaderTitle')
|
|
|
- admin = data['admin'] = Amministratore.objects.get(pk=AdminId)
|
|
|
-
|
|
|
- flag = False
|
|
|
+ print("Sede non esiste")
|
|
|
+ data['sede'] = sede
|
|
|
|
|
|
+ sede = None
|
|
|
if 'SedeIdEdit' in request.session:
|
|
|
print('trovato riferimento SedeIdEdit',request.session.get('SedeIdEdit'))
|
|
|
seid = request.session.get('SedeIdEdit')
|
|
|
@@ -351,66 +405,84 @@ def editSede(request):
|
|
|
sede.forzanuovapassword = sede.azienda.forzanuovapassword
|
|
|
sede.otppassword = sede.azienda.otppassword
|
|
|
|
|
|
- data['permesso_amministratore'] = getAMP(AdminId)[0]
|
|
|
- print('permesso_amministratore',data['permesso_amministratore'])
|
|
|
-
|
|
|
- if flag:
|
|
|
- data['permesso_sede'] = getSEP(sede,AdminId)
|
|
|
- print('permesso_sede',data['permesso_sede'])
|
|
|
-
|
|
|
- data['permesso_azienda'] = getAZP(AziendaId,AdminId)
|
|
|
- print('permesso_azienda',data['permesso_azienda'])
|
|
|
-
|
|
|
- if 'indietro' in request.POST:
|
|
|
- return HttpResponseRedirect(reverse('azienda:welcome'))
|
|
|
+ #### permessi ####
|
|
|
+ data['permesso'] = getAMP(admin)[0]
|
|
|
+ for t in getAZP(azienda,admin):
|
|
|
+ if t not in data['permesso']:
|
|
|
+ data['permesso'].append(t)
|
|
|
+ for t in getSEP(data['sede'],admin):
|
|
|
+ if t not in data['permesso']:
|
|
|
+ data['permesso'].append(t)
|
|
|
+ print('permessi:',data['permesso'])
|
|
|
+ #### permessi ####
|
|
|
|
|
|
if request.method == "POST":
|
|
|
- print("Richiesta creazione nuova azienda")
|
|
|
- nuovasede = formSede(request.POST)
|
|
|
- if nuovasede.is_valid():
|
|
|
- print("il form e' valido",request.POST)
|
|
|
- sede.nome = nuovasede.cleaned_data.get('nome')
|
|
|
- sede.mail = nuovasede.cleaned_data.get('mail')
|
|
|
- sede.cambiopassword = nuovasede.cleaned_data.get('cambiopassword')
|
|
|
- sede.forzanuovapassword = nuovasede.cleaned_data.get('forzanuovapassword')
|
|
|
- sede.otppassword = nuovasede.cleaned_data.get('otppassword')
|
|
|
- sede.info = nuovasede.cleaned_data.get('info')
|
|
|
- sede.identificativo = nuovasede.cleaned_data.get('identificativo')
|
|
|
- sede.save()
|
|
|
- print('salvataggio sede',nuovasede.cleaned_data)
|
|
|
- request.session['SedeIdEdit'] = sede.id
|
|
|
- print('sede:',sede.id)
|
|
|
- print('azienda',sede.azienda.nome)
|
|
|
-
|
|
|
- if 'SedeIdEdit' not in request.session:
|
|
|
- setSEP(sede,data['admin'],"SEDE")
|
|
|
- if 'SEDE.CREA' in getAMP(data['admin'])[0]:
|
|
|
- setSEP(sede,data['admin'],"SEDE.CREA")
|
|
|
- if 'SEDE.EDIT' in getAMP(data['admin'])[0]:
|
|
|
- setSEP(sede,data['admin'],"SEDE.EDIT")
|
|
|
- if 'UTENTE' in getAMP(data['admin'])[0]:
|
|
|
- setSEP(sede,data['admin'],"UTENTE")
|
|
|
- if 'UTENTE.CREA' in getAMP(data['admin'])[0]:
|
|
|
- setSEP(sede,data['admin'],"UTENTE.CREA")
|
|
|
-
|
|
|
- '''
|
|
|
- # verifica assegnazione
|
|
|
- az = AssegnazioneSede.objects.filter(sede=sede,amministratore=admin)
|
|
|
- print('assegnazione',az)
|
|
|
- if not az:
|
|
|
- az = AssegnazioneSede()
|
|
|
- az.sede=sede
|
|
|
- az.amministratore=admin
|
|
|
- az.save()
|
|
|
- print(sede.nome,admin.nome)
|
|
|
- print('az.admin',az.sede,az.amministratore.nome)
|
|
|
- '''
|
|
|
+ print('un tasto è stato premuto')
|
|
|
+
|
|
|
+ if 'indietro' in request.POST:
|
|
|
return HttpResponseRedirect(reverse('azienda:welcome'))
|
|
|
- else:
|
|
|
- print("form non valido")
|
|
|
- data['sedeForm'] = formSede(request.POST)
|
|
|
- else: #non è un post
|
|
|
- print("Non è un post")
|
|
|
+
|
|
|
+ if 'AggiornaSedeButton' in request.POST:
|
|
|
+ print('premuto tasto "AggiornaSedeButton"')
|
|
|
+ nuovasede = formSede(request.POST)
|
|
|
+ if nuovasede.is_valid():
|
|
|
+ print('il form "formSede" è valido')
|
|
|
+
|
|
|
+ sede.nome = nuovasede.cleaned_data.get('nome')
|
|
|
+ sede.mail = nuovasede.cleaned_data.get('mail')
|
|
|
+ sede.cambiopassword = nuovasede.cleaned_data.get('cambiopassword')
|
|
|
+ sede.forzanuovapassword = nuovasede.cleaned_data.get('forzanuovapassword')
|
|
|
+ sede.otppassword = nuovasede.cleaned_data.get('otppassword')
|
|
|
+ sede.info = nuovasede.cleaned_data.get('info')
|
|
|
+ sede.identificativo = nuovasede.cleaned_data.get('identificativo')
|
|
|
+ sede.save()
|
|
|
+
|
|
|
+ request.session['SedeIdEdit'] = sede.id
|
|
|
+ print('sede:',sede.id)
|
|
|
+ print('azienda',sede.nome)
|
|
|
+
|
|
|
+ if not sede:
|
|
|
+ # nel caso la sede non esista, vediamo di crearla
|
|
|
+ if 'SedeIdEdit' not in request.session:
|
|
|
+ setSEP(sede,data['admin'],"SEDE")
|
|
|
+ if 'SEDE.CREA' in getAMP(data['admin'])[0]:
|
|
|
+ setSEP(sede,data['admin'],"SEDE.CREA")
|
|
|
+ if 'SEDE.EDIT' in getAMP(data['admin'])[0]:
|
|
|
+ setSEP(sede,data['admin'],"SEDE.EDIT")
|
|
|
+ if 'UTENTE' in getAMP(data['admin'])[0]:
|
|
|
+ setSEP(sede,data['admin'],"UTENTE")
|
|
|
+ if 'UTENTE.CREA' in getAMP(data['admin'])[0]:
|
|
|
+ setSEP(sede,data['admin'],"UTENTE.CREA")
|
|
|
+ else:
|
|
|
+ data['sedeForm'] = formSede(request.POST)
|
|
|
+
|
|
|
+ if 'CancellaSedePermessiButton' in request.POST:
|
|
|
+ print('premuto "CancellaSedePermessiButton"')
|
|
|
+ cancellasedeamministratoripermessi = request.POST.get('CancellaSedePermessiButton')
|
|
|
+ print('CancellaSedeAmministratoriPermessi',cancellasedeamministratoripermessi)
|
|
|
+ sep = SEP.objects.get(pk=cancellasedeamministratoripermessi)
|
|
|
+ if sep:
|
|
|
+ print('Permesso Sede Amministratore trovato - cancello')
|
|
|
+ sep.delete()
|
|
|
+
|
|
|
+ if 'PermessoDaAggiungereButton' in request.POST:
|
|
|
+ print('premuto "PermessoDaAggiungereButton"')
|
|
|
+ formsedepermessi = formSedePermessi(request.POST,amministratori=Amministratore.objects.all())
|
|
|
+ #formaziendapermessi.c(Amministratore.objects.all()) # alternativa: lista dei soli amministratori con autorizzazione AZIENDA in AMM
|
|
|
+ #print(formaziendapermessi)
|
|
|
+ if formsedepermessi.is_valid():
|
|
|
+ print('formSedePermessi valida')
|
|
|
+ amministratori = formsedepermessi.cleaned_data.get('ListaAmministratoriPermessi')
|
|
|
+ for i in amministratori:
|
|
|
+ print('amministratori da aggiungere',i)
|
|
|
+ setSEP(sede,str(i),"SEDE")
|
|
|
+ else:
|
|
|
+ print('formSedePermessi Errore')
|
|
|
+ print(formsedepermessi)
|
|
|
+
|
|
|
+ formsedefield = None
|
|
|
+ if sede:
|
|
|
+ print('Abbiamo sede',sede.nome)
|
|
|
tmp = dict()
|
|
|
tmp['nome'] = sede.nome
|
|
|
tmp['info'] = sede.info
|
|
|
@@ -419,9 +491,15 @@ def editSede(request):
|
|
|
tmp['forzanuovapassword'] = sede.forzanuovapassword
|
|
|
tmp['otppassword'] = sede.otppassword
|
|
|
print('stato tmp',tmp)
|
|
|
- data['sedeForm'] = formSede(tmp)
|
|
|
- if SedeId:
|
|
|
- data['listaAmministratore'],oggetti = listaAMMperSede(SedeId)
|
|
|
+ formsedefield = formSede(tmp)
|
|
|
+
|
|
|
+ data['sedeForm'] = formsedefield
|
|
|
+
|
|
|
+ print("**** sedeId",SedeId)
|
|
|
+
|
|
|
+ data['listaAmministratore'] = listaAMMperSede(SedeId)[1]
|
|
|
+ print("lamm",data['listaAmministratore'])
|
|
|
+ data['listaAmministratoreDaAggiungere'] = Amministratore.objects.all()
|
|
|
|
|
|
return render(request,'azienda.editSede.html',data)
|
|
|
|