|
|
@@ -130,35 +130,46 @@ def welcome(request):
|
|
|
data['listaok'] = listaok
|
|
|
data['listanotok'] = listanotok
|
|
|
data['count'] = count
|
|
|
-
|
|
|
else:
|
|
|
print('request non valida')
|
|
|
- if 'select' in request.POST:
|
|
|
+
|
|
|
+ if 'MultipleCSVSelect' in request.POST:
|
|
|
#validiamo i dati passati
|
|
|
- SelectResponse = formMultipleCheckBox(request.POST)
|
|
|
- SelectResponse.c(data['utenti'])
|
|
|
+ SelectResponse = formMultipleCheckBoxCSVDOC(request.POST,lista=data['utenti'])
|
|
|
+ poppo = dir(SelectResponse)
|
|
|
+
|
|
|
print("SelectResponse",SelectResponse)
|
|
|
|
|
|
if SelectResponse.is_valid():
|
|
|
- select = SelectResponse.cleaned_data.get('select')
|
|
|
- print('select',select,type(select))
|
|
|
-
|
|
|
- tmplist = list()
|
|
|
- tmplist.append(["Codice Fiscale","Nome","Pin"])
|
|
|
- for i in select:
|
|
|
- print("utente",i)
|
|
|
- if i == '0': continue
|
|
|
- u = Utente.objects.get(pk=int(i))
|
|
|
- tmplist.append([u.codicefiscale,u.nome,u.pin])
|
|
|
- print("lunghezza tmplist",len(tmplist))
|
|
|
-
|
|
|
- f = StringIO()
|
|
|
- csv.writer(f).writerows(tmplist)
|
|
|
- print(f.getvalue())
|
|
|
-
|
|
|
- # scarica il file
|
|
|
- response = FileResponse(f.getvalue(),content_type='application/csv',as_attachment=False)
|
|
|
- response['Content-Disposition'] = 'attachment; filename="lista_dipendenti.csv"'
|
|
|
+ selectCSV = SelectResponse.cleaned_data.get('MultipleCSVSelect')
|
|
|
+ selectDOC = SelectResponse.cleaned_data.get('MultipleDOCSelect')
|
|
|
+
|
|
|
+ selectCSVType=type(selectCSV)
|
|
|
+ selectDOCType=type(selectDOC)
|
|
|
+
|
|
|
+ print('select CSV',selectCSV,selectCSVType)
|
|
|
+ print('select DOC',selectCSV,selectDOCType)
|
|
|
+
|
|
|
+ response = None
|
|
|
+
|
|
|
+ if selectCSV: # la lista selectCSV è valida e contiene l'elenco degli utenti.
|
|
|
+ tmplist = list()
|
|
|
+ tmplist.append(["Codice Fiscale","Nome","Pin"])
|
|
|
+ for i in selectCSV:
|
|
|
+ print("utente",i)
|
|
|
+ if i == '0': continue
|
|
|
+ u = Utente.objects.get(pk=int(i))
|
|
|
+ tmplist.append([u.codicefiscale,u.nome,u.pin])
|
|
|
+ print("lunghezza tmplist",len(tmplist))
|
|
|
+
|
|
|
+ f = StringIO()
|
|
|
+ csv.writer(f,delimiter=';').writerows(tmplist)
|
|
|
+ print(f.getvalue())
|
|
|
+
|
|
|
+ # scarica il file
|
|
|
+ response = FileResponse(f.getvalue(),content_type='application/csv',as_attachment=False)
|
|
|
+ response['Content-Disposition'] = 'attachment; filename="lista_dipendenti.csv"'
|
|
|
+
|
|
|
return response
|
|
|
|
|
|
|