Răsfoiți Sursa

modificato: config/admin.py
modificato: documento/managefile.py
modificato: documento/templates/documento.welcome.html
modificato: documento/views.py

mauro 1 an în urmă
părinte
comite
23431de9ec
89 a modificat fișierele cu 56 adăugiri și 21 ștergeri
  1. BIN
      att/__pycache__/__init__.cpython-311.pyc
  2. BIN
      att/__pycache__/admin.cpython-311.pyc
  3. BIN
      att/__pycache__/apps.cpython-311.pyc
  4. BIN
      att/__pycache__/models.cpython-311.pyc
  5. BIN
      att/__pycache__/views.cpython-311.pyc
  6. BIN
      att/migrations/__pycache__/0001_initial.cpython-311.pyc
  7. BIN
      att/migrations/__pycache__/0002_attivita_utente.cpython-311.pyc
  8. BIN
      att/migrations/__pycache__/0003_alter_attivita_data.cpython-311.pyc
  9. BIN
      att/migrations/__pycache__/0004_attivita_causale_alter_attivita_data.cpython-311.pyc
  10. BIN
      att/migrations/__pycache__/0005_rename_causale_causale_nome_alter_attivita_data.cpython-311.pyc
  11. BIN
      att/migrations/__pycache__/0006_attivita_valore_causale_schema_alter_attivita_data.cpython-311.pyc
  12. BIN
      att/migrations/__pycache__/0007_alter_attivita_amministratore_alter_attivita_azienda_and_more.cpython-311.pyc
  13. BIN
      att/migrations/__pycache__/0008_alter_attivita_data.cpython-311.pyc
  14. BIN
      att/migrations/__pycache__/0009_alter_attivita_data.cpython-311.pyc
  15. BIN
      att/migrations/__pycache__/__init__.cpython-311.pyc
  16. BIN
      azienda/__pycache__/__init__.cpython-311.pyc
  17. BIN
      azienda/__pycache__/admin.cpython-311.pyc
  18. BIN
      azienda/__pycache__/apps.cpython-311.pyc
  19. BIN
      azienda/__pycache__/models.cpython-311.pyc
  20. BIN
      azienda/__pycache__/urls.cpython-311.pyc
  21. BIN
      azienda/__pycache__/views.cpython-311.pyc
  22. BIN
      azienda/migrations/__pycache__/0001_initial.cpython-311.pyc
  23. BIN
      azienda/migrations/__pycache__/0002_rename_a_assegnazione_azienda.cpython-311.pyc
  24. BIN
      azienda/migrations/__pycache__/0003_azienda_azienda_azi_partita_d03251_idx.cpython-311.pyc
  25. BIN
      azienda/migrations/__pycache__/__init__.cpython-311.pyc
  26. BIN
      config/__pycache__/__init__.cpython-311.pyc
  27. BIN
      config/__pycache__/admin.cpython-311.pyc
  28. BIN
      config/__pycache__/apps.cpython-311.pyc
  29. BIN
      config/__pycache__/models.cpython-311.pyc
  30. BIN
      config/__pycache__/views.cpython-311.pyc
  31. 3 1
      config/admin.py
  32. BIN
      config/migrations/__pycache__/0001_initial.cpython-311.pyc
  33. BIN
      config/migrations/__pycache__/0002_config_config_conf_indice_39d8cc_idx_and_more.cpython-311.pyc
  34. BIN
      config/migrations/__pycache__/__init__.cpython-311.pyc
  35. BIN
      db/db.sqlite3
  36. BIN
      documento/__pycache__/__init__.cpython-311.pyc
  37. BIN
      documento/__pycache__/admin.cpython-311.pyc
  38. BIN
      documento/__pycache__/apps.cpython-311.pyc
  39. BIN
      documento/__pycache__/forms.cpython-311.pyc
  40. BIN
      documento/__pycache__/managefile.cpython-311.pyc
  41. BIN
      documento/__pycache__/models.cpython-311.pyc
  42. BIN
      documento/__pycache__/urls.cpython-311.pyc
  43. BIN
      documento/__pycache__/views.cpython-311.pyc
  44. 39 12
      documento/managefile.py
  45. BIN
      documento/migrations/__pycache__/0001_initial.cpython-311.pyc
  46. BIN
      documento/migrations/__pycache__/0002_remove_documento_utente.cpython-311.pyc
  47. BIN
      documento/migrations/__pycache__/0003_remove_documento_dataupload.cpython-311.pyc
  48. BIN
      documento/migrations/__pycache__/0004_documento_utente.cpython-311.pyc
  49. BIN
      documento/migrations/__pycache__/0005_documento_azienda.cpython-311.pyc
  50. BIN
      documento/migrations/__pycache__/0006_documento_documento_d_documen_a68d7b_idx_and_more.cpython-311.pyc
  51. BIN
      documento/migrations/__pycache__/0007_remove_documento_azienda_documento_dataupload.cpython-311.pyc
  52. BIN
      documento/migrations/__pycache__/0008_alter_documento_utente.cpython-311.pyc
  53. BIN
      documento/migrations/__pycache__/0009_documento_descrizione_alter_documento_crc.cpython-311.pyc
  54. BIN
      documento/migrations/__pycache__/0010_documento_azienda.cpython-311.pyc
  55. BIN
      documento/migrations/__pycache__/__init__.cpython-311.pyc
  56. 1 1
      documento/templates/documento.welcome.html
  57. 10 5
      documento/views.py
  58. BIN
      gd/__pycache__/__init__.cpython-311.pyc
  59. BIN
      gd/__pycache__/settings.cpython-311.pyc
  60. BIN
      gd/__pycache__/urls.cpython-311.pyc
  61. BIN
      gd/__pycache__/wsgi.cpython-311.pyc
  62. 3 2
      gd/settings.py
  63. BIN
      login/__pycache__/__init__.cpython-311.pyc
  64. BIN
      login/__pycache__/admin.cpython-311.pyc
  65. BIN
      login/__pycache__/apps.cpython-311.pyc
  66. BIN
      login/__pycache__/forms.cpython-311.pyc
  67. BIN
      login/__pycache__/models.cpython-311.pyc
  68. BIN
      login/__pycache__/urls.cpython-311.pyc
  69. BIN
      login/__pycache__/views.cpython-311.pyc
  70. BIN
      login/migrations/__pycache__/__init__.cpython-311.pyc
  71. BIN
      static/upload/12345678901/MRCMRA66E16Z133L/1722860127.068315.saved
  72. BIN
      static/upload/12345678901/MRCMRA66E16Z133L/1722872434.3403895.saved
  73. BIN
      static/upload/12345678901/VNDLNE84H44A132W/1722858970.4621482.saved
  74. BIN
      utente/__pycache__/__init__.cpython-311.pyc
  75. BIN
      utente/__pycache__/admin.cpython-311.pyc
  76. BIN
      utente/__pycache__/apps.cpython-311.pyc
  77. BIN
      utente/__pycache__/forms.cpython-311.pyc
  78. BIN
      utente/__pycache__/models.cpython-311.pyc
  79. BIN
      utente/__pycache__/urls.cpython-311.pyc
  80. BIN
      utente/__pycache__/views.cpython-311.pyc
  81. BIN
      utente/migrations/__pycache__/0001_initial.cpython-311.pyc
  82. BIN
      utente/migrations/__pycache__/0002_initial.cpython-311.pyc
  83. BIN
      utente/migrations/__pycache__/0003_alter_utente_azienda.cpython-311.pyc
  84. BIN
      utente/migrations/__pycache__/0004_utente_utente_uten_codicef_6e44c2_idx_and_more.cpython-311.pyc
  85. BIN
      utente/migrations/__pycache__/0005_utente_mail.cpython-311.pyc
  86. BIN
      utente/migrations/__pycache__/0006_rename_password_utente_pin.cpython-311.pyc
  87. BIN
      utente/migrations/__pycache__/0007_alter_utente_inserimento.cpython-311.pyc
  88. BIN
      utente/migrations/__pycache__/0008_alter_utente_inserimento.cpython-311.pyc
  89. BIN
      utente/migrations/__pycache__/__init__.cpython-311.pyc

BIN
att/__pycache__/__init__.cpython-311.pyc


BIN
att/__pycache__/admin.cpython-311.pyc


BIN
att/__pycache__/apps.cpython-311.pyc


BIN
att/__pycache__/models.cpython-311.pyc


BIN
att/__pycache__/views.cpython-311.pyc


BIN
att/migrations/__pycache__/0001_initial.cpython-311.pyc


BIN
att/migrations/__pycache__/0002_attivita_utente.cpython-311.pyc


BIN
att/migrations/__pycache__/0003_alter_attivita_data.cpython-311.pyc


BIN
att/migrations/__pycache__/0004_attivita_causale_alter_attivita_data.cpython-311.pyc


BIN
att/migrations/__pycache__/0005_rename_causale_causale_nome_alter_attivita_data.cpython-311.pyc


BIN
att/migrations/__pycache__/0006_attivita_valore_causale_schema_alter_attivita_data.cpython-311.pyc


BIN
att/migrations/__pycache__/0007_alter_attivita_amministratore_alter_attivita_azienda_and_more.cpython-311.pyc


BIN
att/migrations/__pycache__/0008_alter_attivita_data.cpython-311.pyc


BIN
att/migrations/__pycache__/0009_alter_attivita_data.cpython-311.pyc


BIN
att/migrations/__pycache__/__init__.cpython-311.pyc


BIN
azienda/__pycache__/__init__.cpython-311.pyc


BIN
azienda/__pycache__/admin.cpython-311.pyc


BIN
azienda/__pycache__/apps.cpython-311.pyc


BIN
azienda/__pycache__/models.cpython-311.pyc


BIN
azienda/__pycache__/urls.cpython-311.pyc


BIN
azienda/__pycache__/views.cpython-311.pyc


BIN
azienda/migrations/__pycache__/0001_initial.cpython-311.pyc


BIN
azienda/migrations/__pycache__/0002_rename_a_assegnazione_azienda.cpython-311.pyc


BIN
azienda/migrations/__pycache__/0003_azienda_azienda_azi_partita_d03251_idx.cpython-311.pyc


BIN
azienda/migrations/__pycache__/__init__.cpython-311.pyc


BIN
config/__pycache__/__init__.cpython-311.pyc


BIN
config/__pycache__/admin.cpython-311.pyc


BIN
config/__pycache__/apps.cpython-311.pyc


BIN
config/__pycache__/models.cpython-311.pyc


BIN
config/__pycache__/views.cpython-311.pyc


+ 3 - 1
config/admin.py

@@ -1,4 +1,6 @@
 from django.contrib import admin
 from .models import *
 
-admin.site.register(Config)
+@admin.register(Config)
+class Configurazione(admin.ModelAdmin):
+  list_display = ['indice','valore',]

BIN
config/migrations/__pycache__/0001_initial.cpython-311.pyc


BIN
config/migrations/__pycache__/0002_config_config_conf_indice_39d8cc_idx_and_more.cpython-311.pyc


BIN
config/migrations/__pycache__/__init__.cpython-311.pyc


BIN
db/db.sqlite3


BIN
documento/__pycache__/__init__.cpython-311.pyc


BIN
documento/__pycache__/admin.cpython-311.pyc


BIN
documento/__pycache__/apps.cpython-311.pyc


BIN
documento/__pycache__/forms.cpython-311.pyc


BIN
documento/__pycache__/managefile.cpython-311.pyc


BIN
documento/__pycache__/models.cpython-311.pyc


BIN
documento/__pycache__/urls.cpython-311.pyc


BIN
documento/__pycache__/views.cpython-311.pyc


+ 39 - 12
documento/managefile.py

@@ -22,12 +22,12 @@ from codicefiscale import codicefiscale
 import os
 
 # come sono gestiti i file nella configurazione:
-# MEDIA_ROOT=os.path.join(BASE_DIR,'static/upload')
-# che diventa = os.path.join(BASE_DIR,getConfig('DocPath'))
+# MEDIA_ROOT=os.path.join(settings.BASE_DIR,'static/upload')
+# che diventa = os.path.join(settings.BASE_DIR,getConfig('DocPath'))
 
 def delete_file(documento):
   # questo blocco rimuove fisicamente il file prima della sua rimozione logica nel db
-  file_path = os.path.join(BASE_DIR,getConfig('DocPath'),documento.utente.azienda.partitaiva,documento.utente.codicefiscale,documento.storage)
+  file_path = os.path.join(settings.BASE_DIR,getConfig('DocPath'),documento.utente.azienda.partitaiva,documento.utente.codicefiscale,documento.storage)
   print('Path completa:',file_path)
   if os.path.isfile(file_path):
     print('rimozione fisica file:',posizione)  
@@ -38,7 +38,7 @@ def delete_file(documento):
 
 def download_file(request,uid):
     utente = Utenti.objects.get(pk=uid)
-    file_path = os.path.join(BASE_DIR,getConfig('DocPath'),documento.utente.azienda.partitaiva,documento.utente.codicefiscale,utente.storage)
+    file_path = os.path.join(settings.BASE_DIR,getConfig('DocPath'),documento.utente.azienda.partitaiva,documento.utente.codicefiscale,utente.storage)
     print('Path completa da Basedir:',file_path)
     if utente.storage and os.path.isfile(file_path):
       try:
@@ -67,8 +67,9 @@ def upload_file(uploaded_file,utente,originale=False):
   caricamento files
   '''
   stored_file = ''.join((str(time.time()),'.saved'))
-  fl_path = os.path.join(BASE_DIR,getConfig('DocPath'))
+  fl_path = os.path.join(settings.BASE_DIR,getConfig('DocPath'))
   print('nome file',uploaded_file.name,stored_file)
+
   nomefile=None
   if originale:
     nomefile = uploaded_file.name
@@ -83,6 +84,7 @@ def upload_file(uploaded_file,utente,originale=False):
   # utente.codicefiscale (prima era "record" e mi sono deciso a cambiarlo)
 
   try:
+    print(os.path.join(fl_path,utente.azienda.partitaiva))
     os.mkdir(os.path.join(fl_path,utente.azienda.partitaiva))
   except FileExistsError as fee:
     print(os.path.join(fl_path,utente.azienda.partitaiva),"esistente")
@@ -99,6 +101,28 @@ def upload_file(uploaded_file,utente,originale=False):
     return os.path.join(fl_path,utente.azienda.partitaiva,utente.codicefiscale,nomefile)
   return stored_file
 
+def upload_file_indice(uploaded_file):
+  # caricamento file indice (gestito in modo diverso)
+
+  stored_file = ''.join((str(time.time()),'.saved'))
+  fl_path = os.path.join(settings.BASE_DIR,getConfig('DocPath'),getConfig('DocPathIndex'))
+  print('nome file',uploaded_file.name,stored_file)
+
+  # verifica l'esistenza della directory
+  try:
+    os.mkdir(fl_path)
+  except FileExistsError as fee:
+    print(fl_path,"esistente")
+
+  print('file_memorizzato',os.path.join(fl_path,stored_file))
+
+  with open(os.path.join(fl_path,stored_file),'wb+') as d:
+    for chunk in uploaded_file.chunks():
+      d.write(chunk)
+
+  return stored_file
+
+##################################################################################
 def save_and_load_file_multiple(listadocumenti,request,utente,azienda,descrizione):
   listaok = list()
   listanotok = list()
@@ -145,23 +169,25 @@ def save_and_load_file_single(listadocumenti,request,utente,azienda,descrizione)
       listanotok.append(documento.documento)
   return (listaok,listanotok)
 
-def save_and_load_file_indice(fileindice,request,documento):
+def save_and_load_file_indice(request,fileindice,documento):
   print('nome indice caricato',fileindice.name)
-  upload_file(fileindice,request.FILES['indice'],True)
-  fl_path = getConfig('DocPath')
 
+  file_memorizzato = upload_file_indice(request.FILES['indice'])
+
+  fl_path = os.path.join(getConfig('DocPath'),getConfig('DocPathIndex'))
+  
   risultato = None
-  with open(os.path.join(fl_path,fileindice.name),'rb') as ind:
+  with open(os.path.join(fl_path,file_memorizzato),'rb') as ind:
     risultato = ind.read()
     risultato = risultato.decode('utf-8',errors='replace')
     if isinstance(risultato,str):
       risultato = risultato.encode('utf8')
 
-    with open(os.path.join(fl_path,fileindice.name,'.cvtd'),'wb') as ind:
+    with open(os.path.join(fl_path,''.join((file_memorizzato,'.cvtd'))),'wb') as ind:
       ind.write(risultato)
       print('una volta convertito, passiamo oltre')
     
-    with open(os.path.join(fl_path,'/',fileindice.name,'.cvtd'),'rt') as ind:
+    with open(os.path.join(fl_path,''.join((file_memorizzato,'.cvtd'))),'rt') as ind:
         spamreader = csv.reader(ind,delimiter=';')
         errori = list()
         count = 0
@@ -204,6 +230,7 @@ def save_and_load_file_indice(fileindice,request,documento):
               utente.password = str(randint(100000,999999))
               utente.save()
 
+'''
     # caricamento documenti
     if filecaricati.cleaned_data.get('allegati'):
       print('presenti documenti da allegare')
@@ -220,4 +247,4 @@ def save_and_load_file_indice(fileindice,request,documento):
             # risultato: nome del file memorizzato (nome interno)
             # singolodocumento.name = nome del file originale
 
-
+'''

BIN
documento/migrations/__pycache__/0001_initial.cpython-311.pyc


BIN
documento/migrations/__pycache__/0002_remove_documento_utente.cpython-311.pyc


BIN
documento/migrations/__pycache__/0003_remove_documento_dataupload.cpython-311.pyc


BIN
documento/migrations/__pycache__/0004_documento_utente.cpython-311.pyc


BIN
documento/migrations/__pycache__/0005_documento_azienda.cpython-311.pyc


BIN
documento/migrations/__pycache__/0006_documento_documento_d_documen_a68d7b_idx_and_more.cpython-311.pyc


BIN
documento/migrations/__pycache__/0007_remove_documento_azienda_documento_dataupload.cpython-311.pyc


BIN
documento/migrations/__pycache__/0008_alter_documento_utente.cpython-311.pyc


BIN
documento/migrations/__pycache__/0009_documento_descrizione_alter_documento_crc.cpython-311.pyc


BIN
documento/migrations/__pycache__/0010_documento_azienda.cpython-311.pyc


BIN
documento/migrations/__pycache__/__init__.cpython-311.pyc


+ 1 - 1
documento/templates/documento.welcome.html

@@ -45,7 +45,7 @@
       <tbody>
         {% for documento in ElencoDocumentiPerAzienda %}
         <tr>
-          <td> <button type='button' class='btn btn-primary btn-block btn-lg mb-2 active' onclick="window.open('{% url "documento:finalize" documento.id %}')">Vedi</button></td>
+          <td> <button type='button' class='btn btn-primary btn-block btn-lg mb-2 active' onclick="window.open('{% url "documento:finalize" documento.id documento.utente.id%}')">Vedi</button></td>
           <td> {{ documento.utente.nome }} </td>
           <td> {{ documento.documento }} </td>
           <td> {{ documento.storage}} </td>

+ 10 - 5
documento/views.py

@@ -65,15 +65,16 @@ def welcome(request):
       d.delete()
 
     filecaricati = AdminUpload(request.POST,request.FILES)
+
     if filecaricati.is_valid():
+
       print('record filecaricati validi')
-      if filecaricati.cleaned_data.get('indice'):
-        print('presente file indice')
+      if 'indice' in filecaricati.cleaned_data and filecaricati.cleaned_data.get('indice'):
         fileindice = filecaricati.cleaned_data.get('indice')
-        print(fileindice)
-        save_and_load_file_indice(fileindice,request,azienda)
+        print('presente file indice',fileindice)
+        save_and_load_file_indice(request,fileindice,azienda)
 
-      if filecaricati.cleaned_data.get('allegati'):
+      if 'allegati' in filecaricati.cleaned_data and filecaricati.cleaned_data.get('allegati'):
         print('presenti documenti da allegare')
         listadocumenti = filecaricati.cleaned_data['allegati']
         print(listadocumenti)
@@ -94,6 +95,8 @@ def finalize_download(request,did,uid=None):
   viene comunicato l'utente
   viene cercato il file memorizzato e viene riconsegnato 
   con il nome originale
+  did: documento id
+  uid: user id
   '''
 
   UserId = None
@@ -107,7 +110,9 @@ def finalize_download(request,did,uid=None):
 
   if 'UserId' in request.session:
     UserId = request.session['UserId']
+    print('UserId in request session',Userid)
   else:
+    print('UserId passed by func',uid)
     UserId = uid
 
   utente = Utente.objects.get(pk=UserId)

BIN
gd/__pycache__/__init__.cpython-311.pyc


BIN
gd/__pycache__/settings.cpython-311.pyc


BIN
gd/__pycache__/urls.cpython-311.pyc


BIN
gd/__pycache__/wsgi.cpython-311.pyc


+ 3 - 2
gd/settings.py

@@ -134,6 +134,7 @@ DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
 #la sessione comunque scade alla chiusura del browser
 SESSION_EXPIRE_AT_BROWSER_CLOSE=True
 
-MEDIA_ROOT=os.path.join(BASE_DIR,'static/upload')
-STATICFILES_DIRS = [ os.path.join(BASE_DIR,'static/upload'), ]
+#MEDIA_ROOT=os.path.join(BASE_DIR,'static/upload')
+
+#STATICFILES_DIRS = [ os.path.join(BASE_DIR,'static/upload'), ]
 

BIN
login/__pycache__/__init__.cpython-311.pyc


BIN
login/__pycache__/admin.cpython-311.pyc


BIN
login/__pycache__/apps.cpython-311.pyc


BIN
login/__pycache__/forms.cpython-311.pyc


BIN
login/__pycache__/models.cpython-311.pyc


BIN
login/__pycache__/urls.cpython-311.pyc


BIN
login/__pycache__/views.cpython-311.pyc


BIN
login/migrations/__pycache__/__init__.cpython-311.pyc


BIN
static/upload/12345678901/MRCMRA66E16Z133L/1722860127.068315.saved


BIN
static/upload/12345678901/MRCMRA66E16Z133L/1722872434.3403895.saved


BIN
static/upload/12345678901/VNDLNE84H44A132W/1722858970.4621482.saved


BIN
utente/__pycache__/__init__.cpython-311.pyc


BIN
utente/__pycache__/admin.cpython-311.pyc


BIN
utente/__pycache__/apps.cpython-311.pyc


BIN
utente/__pycache__/forms.cpython-311.pyc


BIN
utente/__pycache__/models.cpython-311.pyc


BIN
utente/__pycache__/urls.cpython-311.pyc


BIN
utente/__pycache__/views.cpython-311.pyc


BIN
utente/migrations/__pycache__/0001_initial.cpython-311.pyc


BIN
utente/migrations/__pycache__/0002_initial.cpython-311.pyc


BIN
utente/migrations/__pycache__/0003_alter_utente_azienda.cpython-311.pyc


BIN
utente/migrations/__pycache__/0004_utente_utente_uten_codicef_6e44c2_idx_and_more.cpython-311.pyc


BIN
utente/migrations/__pycache__/0005_utente_mail.cpython-311.pyc


BIN
utente/migrations/__pycache__/0006_rename_password_utente_pin.cpython-311.pyc


BIN
utente/migrations/__pycache__/0007_alter_utente_inserimento.cpython-311.pyc


BIN
utente/migrations/__pycache__/0008_alter_utente_inserimento.cpython-311.pyc


BIN
utente/migrations/__pycache__/__init__.cpython-311.pyc