|
|
@@ -41,7 +41,7 @@ def welcome(request):
|
|
|
data['permesso'].append(t)
|
|
|
if 'sede' in data:
|
|
|
print('**** sede presente ****')
|
|
|
- for t in getSEP(data['sede'],data['admin']):
|
|
|
+ for t in getSEP(data['sede'],data['admin'])[0]:
|
|
|
if t not in data['permesso']:
|
|
|
data['permesso'].append(t)
|
|
|
print('permessi assegnati:',data['permesso'])
|
|
|
@@ -293,6 +293,10 @@ def editAMP(request):
|
|
|
print("Un tasto èstato premuto 'AmministratoreReturnButton'")
|
|
|
return HttpResponseRedirect(reverse("amministratore:welcome"))
|
|
|
|
|
|
+ if 'indietro' in request.POST:
|
|
|
+ print("Un tasto è stato premuto 'Indietro'")
|
|
|
+ return HttpResponseRedirect(reverse("azienda:welcome"))
|
|
|
+
|
|
|
formpermessodaaggiungere = FormPermessoDaAggiungere(request.POST,permessi=data['listapermessiassegnabili'])
|
|
|
if formpermessodaaggiungere.is_valid():
|
|
|
print('formpermessodaaggiungere valido')
|
|
|
@@ -389,6 +393,10 @@ def editAZ(request):
|
|
|
print("Un tasto è stato premuto 'AmministratoreButton'")
|
|
|
return HttpResponseRedirect(reverse("amministratore:edit"))
|
|
|
|
|
|
+ if 'indietro' in request.POST:
|
|
|
+ print("Un tasto è stato premuto 'Indietro'")
|
|
|
+ return HttpResponseRedirect(reverse("azienda:welcome"))
|
|
|
+
|
|
|
if 'AziendaDaAggiungereButton' in request.POST:
|
|
|
print('un tasto è stato premuto AziendaDaAggiungereButton')
|
|
|
formaziendadaaggiungere = FormAziendaDaAggiungere(request.POST,azienda=listaaziendatutte)
|
|
|
@@ -404,7 +412,7 @@ def editAZ(request):
|
|
|
print("Un tasto è stato premuto 'SedeButton'")
|
|
|
azienda = request.POST.get('SedeButton')
|
|
|
request.session['EditAziendaId'] = azienda
|
|
|
- return HttpResponseRedirect(reverse("amministratore:editSEP"))
|
|
|
+ return HttpResponseRedirect(reverse("amministratore:editSE"))
|
|
|
|
|
|
if 'PermessoButton' in request.POST:
|
|
|
print("Un tasto è stato premuto 'PermessoButton")
|
|
|
@@ -505,6 +513,10 @@ def editAZP(request):
|
|
|
print("Un tasto è stato premuto 'AmministratoreButton'")
|
|
|
return HttpResponseRedirect(reverse("amministratore:edit"))
|
|
|
|
|
|
+ if 'AmministratoreAziendaButton' in request.POST:
|
|
|
+ print("Un tasto è stato premuto 'AmministratoreAziendaButton'")
|
|
|
+ return HttpResponseRedirect(reverse("amministratore:editAZ"))
|
|
|
+
|
|
|
if 'PermessoDaAggiungereButton' in request.POST:
|
|
|
print("Un tasto è stato premuto 'PermessoDaAggiungereButton'")
|
|
|
formpermessodaaggiungere = FormPermessoDaAggiungere(request.POST,permessi=data['listapermessiassegnabili'])
|
|
|
@@ -514,6 +526,10 @@ def editAZP(request):
|
|
|
else:
|
|
|
print('errore formpermessodaaggiungere',formpermessodaaggiungere)
|
|
|
|
|
|
+ if 'indietro' in request.POST:
|
|
|
+ print("Un tasto è stato premuto 'Indietro'")
|
|
|
+ return HttpResponseRedirect(reverse("azienda:welcome"))
|
|
|
+
|
|
|
if 'ConfermaCancellazionePermesso' in request.POST:
|
|
|
print("Un tasto è stato premuto 'ConfermaCancellazionePermesso'")
|
|
|
delAZP(azienda,amministratore,int(request.POST.get('ConfermaCancellazionePermesso')))
|
|
|
@@ -537,7 +553,7 @@ def editAZP(request):
|
|
|
|
|
|
return render(request,'amministratore.edit.AZP.html',data)
|
|
|
|
|
|
-def editSEP(request):
|
|
|
+def editSE(request):
|
|
|
### edit diritti associati alla sede
|
|
|
### in questa sezione procediamo con l'assegnare o rimuovere i diritti di questo amministratore
|
|
|
### per le sedi in elenco.
|
|
|
@@ -576,7 +592,7 @@ def editSEP(request):
|
|
|
try:
|
|
|
amministratore = Amministratore.objects.get(pk=amministratoreEditId)
|
|
|
except Amministratore.DoesNotExist as dne:
|
|
|
- return HttpResponseRedirect(reverse("amministratore:editSEP"))
|
|
|
+ return HttpResponseRedirect(reverse("amministratore:editSE"))
|
|
|
|
|
|
print('amministratore',amministratore.id,amministratore.login,amministratore.nome)
|
|
|
data['amministratore'] = amministratore
|
|
|
@@ -613,10 +629,20 @@ def editSEP(request):
|
|
|
print("Un tasto è stato premuto 'AmministratoreButton'")
|
|
|
return HttpResponseRedirect(reverse("amministratore:edit"))
|
|
|
|
|
|
+ if 'AmministratoreAziendaButton' in request.POST:
|
|
|
+ print("Un tasto è stato premuto 'AmministratoreAziendaButton'")
|
|
|
+ return HttpResponseRedirect(reverse("amministratore:editAZ"))
|
|
|
+
|
|
|
if 'AmministratoreEditAZPButton' in request.POST:
|
|
|
print("Un tasto è stato premuto 'AmministratoreEditAZPButton'")
|
|
|
return HttpResponseRedirect(reverse("amministratore:editAZ"))
|
|
|
|
|
|
+ if 'PermessoButton' in request.POST:
|
|
|
+ print("Un tasto è stato premuto 'PermessoButton")
|
|
|
+ sede = request.POST.get('PermessoButton')
|
|
|
+ request.session['EditSedePermessoId'] = sede
|
|
|
+ return HttpResponseRedirect(reverse("amministratore:editSEP"))
|
|
|
+
|
|
|
if 'SedeConfermaCancellazionePermessoButton' in request.POST:
|
|
|
print("un tasto è stato premuto 'SedeConfermaCancellazionePermessoButton'")
|
|
|
sede = request.POST['SedeConfermaCancellazionePermessoButton']
|
|
|
@@ -678,6 +704,127 @@ def editSEP(request):
|
|
|
data['dirittiSEDE'] = Permesso.objects.filter(classe='SED')
|
|
|
print('dirittiSEDE',len(data['dirittiSEDE']))
|
|
|
|
|
|
+ return render(request,'amministratore.edit.SE.html',data)
|
|
|
+
|
|
|
+def editSEP(request):
|
|
|
+ ### edit diritti associati all sede.
|
|
|
+ ### in questa sezione procediamo con l'assegnare o rimuovere i diritti di questo amministratore
|
|
|
+ ### per le aziende in elenco.
|
|
|
+
|
|
|
+ if not 'AdminId' in request.session:
|
|
|
+ return HttpResponseRedirect(reverse("login:start"))
|
|
|
+
|
|
|
+ ### funzioni esterne ###
|
|
|
+ d = DataDict()
|
|
|
+ data = d.getData()
|
|
|
+ data['NavBar']=True
|
|
|
+ data['ShowSelectAzienda'] = False
|
|
|
+ data['ShowSelectSede'] = False
|
|
|
+
|
|
|
+ define = Define(request)
|
|
|
+ data['admin'] = define.getAdmin()
|
|
|
+ data['azienda'] = define.getAzienda()
|
|
|
+ data['AziendaId'] = define.getAziendaId()
|
|
|
+ data['sede'] = define.getSede()
|
|
|
+ data['SedeId'] = define.getSedeId()
|
|
|
+ ### funzioni esterne fine ###
|
|
|
+
|
|
|
+ if 'AdminId' in request.session:
|
|
|
+ data['AdminId'] = request.session['AdminId']
|
|
|
+ admin = Amministratore.objects.get(pk=data['AdminId'])
|
|
|
+ data['admin'] = admin
|
|
|
+ print('admin',admin.id,admin.nome)
|
|
|
+ data['permessoSEP'] = getAMP(admin)[1]
|
|
|
+
|
|
|
+ amministratore = None
|
|
|
+ if 'AmministratoreEditId' in request.session:
|
|
|
+ amministratoreEditId = request.session.get('AmministratoreEditId')
|
|
|
+ try:
|
|
|
+ amministratore = Amministratore.objects.get(pk=amministratoreEditId)
|
|
|
+ except Amministratore.DoesNotExist as dne:
|
|
|
+ return HttpResponseRedirect(reverse("amministratore:edit"))
|
|
|
+
|
|
|
+ print('amministratore',amministratore.id,amministratore.login,amministratore.nome)
|
|
|
+ data['amministratore'] = amministratore
|
|
|
+
|
|
|
+ if 'EditSedePermessoId' in request.session:
|
|
|
+ sede = Sede.objects.get(pk=request.session.get('EditSedePermessoId'))
|
|
|
+ print('sede',sede.nome)
|
|
|
+ data['sedeOnWork'] = sede
|
|
|
+ data['permessoSEP'] = getSEP(sede,amministratore)[1]
|
|
|
+ print('PermessoSEP',data['permessoSEP'])
|
|
|
+
|
|
|
+ if 'paramm' in request.session and request.session['paramm']:
|
|
|
+ data['DONTSHOWDIRITTI']=True
|
|
|
+
|
|
|
+ print('amministratore',amministratore.id,amministratore.login,amministratore.nome)
|
|
|
+ data['amministratore'] = amministratore
|
|
|
+
|
|
|
+ ####################################
|
|
|
+ listadirittidisponibili= Permesso.objects.filter(Q(classe='SED')|Q(classe='UTE')|Q(classe='DOC'))
|
|
|
+
|
|
|
+ # diciamo che fatta cosi' mi pare una pecionata, ma funzionata. magari va ottimizzata un po'
|
|
|
+ print(type(listadirittidisponibili))
|
|
|
+ ldd = list()
|
|
|
+ for i in listadirittidisponibili:
|
|
|
+ ldd.append(i)
|
|
|
+ print(type(ldd))
|
|
|
+ print('*' * 20)
|
|
|
+ data['listapermessiassegnabili'] = list()
|
|
|
+ for i in ldd:
|
|
|
+ if i not in data['permessoSEP']:
|
|
|
+ data['listapermessiassegnabili'].append(i)
|
|
|
+ ##########################################
|
|
|
+
|
|
|
+ if request.method == 'POST':
|
|
|
+ print("qualcosa e' stato premuto")
|
|
|
+
|
|
|
+ if 'AmministratoreReturnButton' in request.POST:
|
|
|
+ print("Un tasto è stato premuto 'AmministratoreReturnButton'")
|
|
|
+ return HttpResponseRedirect(reverse("amministratore:welcome"))
|
|
|
+
|
|
|
+ if 'AmministratoreButton' in request.POST:
|
|
|
+ print("Un tasto è stato premuto 'AmministratoreButton'")
|
|
|
+ return HttpResponseRedirect(reverse("amministratore:edit"))
|
|
|
+
|
|
|
+ if 'AmministratoreAziendaButton' in request.POST:
|
|
|
+ print("Un tasto è stato premuto 'AmministratoreAziendeButton'")
|
|
|
+ return HttpResponseRedirect(reverse("amministratore:editAZ"))
|
|
|
+
|
|
|
+ if 'AmministratoreSedeButton' in request.POST:
|
|
|
+ print("Un tasto è stato premuto 'AmministratoreAziendeButton'")
|
|
|
+ return HttpResponseRedirect(reverse("amministratore:editSE"))
|
|
|
+
|
|
|
+ if 'PermessoDaAggiungereButton' in request.POST:
|
|
|
+ print("Un tasto è stato premuto 'PermessoDaAggiungereButton'")
|
|
|
+ formpermessodaaggiungere = FormPermessoDaAggiungere(request.POST,permessi=data['listapermessiassegnabili'])
|
|
|
+ if formpermessodaaggiungere.is_valid():
|
|
|
+ print('listapermessidaaggiungere',formpermessodaaggiungere.cleaned_data.get('ListaPermessiDaAggiungere'))
|
|
|
+ setSEP(sede,amministratore,int(formpermessodaaggiungere.cleaned_data.get('ListaPermessiDaAggiungere')))
|
|
|
+ else:
|
|
|
+ print('errore formpermessodaaggiungere',formpermessodaaggiungere)
|
|
|
+
|
|
|
+ if 'ConfermaCancellazionePermesso' in request.POST:
|
|
|
+ print("Un tasto è stato premuto 'ConfermaCancellazionePermesso'")
|
|
|
+ delSEP(azienda,amministratore,int(request.POST.get('ConfermaCancellazionePermesso')))
|
|
|
+
|
|
|
+ data['permessoSEP'] = getSEP(sede,amministratore)[1]
|
|
|
+ ####################################
|
|
|
+ listadirittidisponibili= Permesso.objects.filter(Q(classe='SED')|Q(classe='UTE')|Q(classe='DOC'))
|
|
|
+
|
|
|
+ # diciamo che fatta cosi' mi pare una pecionata, ma funzionata. magari va ottimizzata un po'
|
|
|
+ print(type(listadirittidisponibili))
|
|
|
+ ldd = list()
|
|
|
+ for i in listadirittidisponibili:
|
|
|
+ ldd.append(i)
|
|
|
+ print(type(ldd))
|
|
|
+ print('*' * 20)
|
|
|
+ data['listapermessiassegnabili'] = list()
|
|
|
+ for i in ldd:
|
|
|
+ if i not in data['permessoSEP']:
|
|
|
+ data['listapermessiassegnabili'].append(i)
|
|
|
+ ##########################################
|
|
|
+
|
|
|
return render(request,'amministratore.edit.SEP.html',data)
|
|
|
|
|
|
'''
|