|
|
@@ -153,8 +153,7 @@ def welcome(request):
|
|
|
if not 'AdminId' in request.session or 'UserId' in request.session:
|
|
|
print("Non rilevo presensa UserId e AdminId in request.session")
|
|
|
return HttpResponseRedirect(reverse("login:start"))
|
|
|
-
|
|
|
- if 'AdminId' in request.session:
|
|
|
+ else:
|
|
|
data['AdminId'] = request.session['AdminId']
|
|
|
|
|
|
if 'UserId' in request.session:
|
|
|
@@ -166,11 +165,12 @@ def welcome(request):
|
|
|
|
|
|
data['azienda'] = Azienda.objects.get(pk=data['AziendaId'])
|
|
|
data['comunicazione'] = data['azienda'].comunicazione_set.all()
|
|
|
+ data['comm'] = data['azienda'].comm
|
|
|
print(data)
|
|
|
|
|
|
-
|
|
|
if request.method == "POST":
|
|
|
print('Richiesta effettuata')
|
|
|
+ print(request.POST)
|
|
|
|
|
|
if 'Ritorna' in request.POST:
|
|
|
return HttpResponseRedirect(reverse("azienda:welcome"))
|
|
|
@@ -178,12 +178,55 @@ def welcome(request):
|
|
|
fd = formDocumento(request.POST)
|
|
|
if fd.is_valid():
|
|
|
print('documento valido')
|
|
|
+ else:
|
|
|
+ print('documento non valido')
|
|
|
+ data['documento'] = formDocumento(request.POST)
|
|
|
|
|
|
+ else:
|
|
|
+ data['documento'] = formDocumento()
|
|
|
+
|
|
|
return render(request,'comunicazione.welcome.html',data)
|
|
|
|
|
|
|
|
|
|
|
|
'''
|
|
|
+
|
|
|
+ def edit(request):
|
|
|
+ AdminId = request.session['AdminId']
|
|
|
+
|
|
|
+ data={}
|
|
|
+ data['HeaderTitle'] = getConfig('HeaderTitle')
|
|
|
+ data['admin' ] = User.objects.get(pk=AdminId)
|
|
|
+
|
|
|
+ if request.method == "POST":
|
|
|
+ print("Richiesta creazione nuova azienda")
|
|
|
+ nuovaazienda = formAzienda(request.POST)
|
|
|
+ if nuovaazienda.is_valid():
|
|
|
+ print("il form e' valido",request.POST)
|
|
|
+ azienda = Azienda()
|
|
|
+ azienda.nome = nuovaazienda.cleaned_data.get('nome')
|
|
|
+ azienda.mail = nuovaazienda.cleaned_data.get('mail')
|
|
|
+ azienda.partitaiva = nuovaazienda.cleaned_data.get('partitaiva')
|
|
|
+ azienda.save()
|
|
|
+ request.session['AziendaId'] = azienda.id
|
|
|
+ assegnazione = Assegnazione()
|
|
|
+ assegnazione.azienda=azienda
|
|
|
+ assegnazione.user=User.objects.get(pk=AdminId)
|
|
|
+ assegnazione.save()
|
|
|
+ return HttpResponseRedirect(reverse('azienda:welcome'))
|
|
|
+ else:
|
|
|
+ print("form non valido")
|
|
|
+ data['azienda'] = formAzienda(request.POST)
|
|
|
+
|
|
|
+ else: #non è un post
|
|
|
+ print("Non è un post")
|
|
|
+ formAziendaField = formAzienda()
|
|
|
+ data['azienda'] = formAziendaField
|
|
|
+
|
|
|
+ return render(request,'azienda.edit.html',data)
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
#filtro:
|
|
|
# selezionare tutti gli utenti per AziendaId
|
|
|
admin = User.objects.get(pk=data['AdminId'])
|