浏览代码

nel caricamento file indice, gestiti file con righe vuote

Mauro 8 月之前
父节点
当前提交
5132794e75
共有 3 个文件被更改,包括 9 次插入15 次删除
  1. 3 3
      documento/managefile.py
  2. 1 11
      utente/templates/utente.welcome.html
  3. 5 1
      utente/views.py

+ 3 - 3
documento/managefile.py

@@ -296,8 +296,8 @@ def save_and_load_file_indice(request,fileindice,azienda=None,sede=None):
           if count==1: continue
           print(count,'sr',sr,len(sr))
 
-          if len(sr) >= 1: # la lunghezza del record segnala qualcosa
-            print('lunghezza ok',sr[0])
+          if len(sr) >= 1 and len("".join(sr)) > 0: # la lunghezza del record segnala qualcosa
+            print('record sr',sr)
             utente = None
             codicefiscale = sr[1].strip()
             print('codice fiscale',sr[1].strip().upper())
@@ -348,7 +348,7 @@ def save_and_load_file_indice(request,fileindice,azienda=None,sede=None):
                 print("Codice Fiscale NON valido o mancante")
                 listaNotOk.append({"nome":utente.nome,"codicefiscale":utente.codicefiscale,"errore":"Codice Fiscale"})
 
-  return (listaOk,listaNotOk)
+  return (listaOk,listaNotOk,count)
 
 def PrepareZipFile(listafile=[]):
   zip_path = os.path.join(settings.BASE_DIR,getConfig('DocZipFile'))

+ 1 - 11
utente/templates/utente.welcome.html

@@ -167,17 +167,7 @@ function toggle(source) {
     </table>
   {% endif %}
 
-  {% if listaok %}
-    {% for i in listaok %}
-      {{i }}
-    {% endfor %}
-  {% endif %}
-
-  {% if listanotok %}
-    {% for i in listanotok %}
-      {{i }}
-    {% endfor %}
-  {% endif %}
+  totale record letti nel file: {{ count }}
 
 {% endblock %}
 

+ 5 - 1
utente/views.py

@@ -130,7 +130,11 @@ def welcome(request):
           print('record filecaricati validi')
           print('presente file indice')
           fileindiceottenuto = fileindicecaricato.cleaned_data.get('indice')
-          save_and_load_file_indice(request,fileindiceottenuto,data['azienda'],data['sede'])
+          listaok,listanotok,count = save_and_load_file_indice(request,fileindiceottenuto,data['azienda'],data['sede'])
+          data['listaok'] = listaok
+          data['listanotok'] = listanotok
+          data['count'] = count
+
         else:
           print('request non valida')
       if 'select' in request.POST: