فهرست منبع

modified: documento/templates/documento.welcome.html
modified: documento/views.py
deleted: static/upload/12345678901/MRCMRA66E16Z133L/1723206972.642314.saved

Mauro 1 سال پیش
والد
کامیت
de8d49f2eb

+ 28 - 21
documento/templates/documento.welcome.html

@@ -88,27 +88,34 @@
   <div>
   <br>
   </div>
-  <form name='upload' method='post' enctype='multipart/form-data'>
-    {% csrf_token %}
-    <table class='table table-striped table-hover'>
-      <tbody>
-        <tr>
-         <form name='upload' method='post' enctype='multipart/form-data'>
-           {% csrf_token %}
-
-           <td><label for='indice'>Indice Utenti:&nbsp;</label>
-               <input type='file' class="btn btn-primary" name='indice' id='indice' value='{{ uf.indice }}' accept='text/csv'></td>
-
-           <td><label for='descrizione'>Descrizione:&nbsp;</label>
-               <input type='text' name='descrizione' id='descrizione' value=''>
-               <input type='file' class="btn btn-primary" name='allegati' id='allegati' value='{{ uf.allegati }}' accept='application/pdf' multiple></td>
-           <td><input type='submit' class="btn btn-primary" value='Inserisci'><td>
-           <td><input type='submit' class="btn btn-primary" name='ritorna' value='Ritorna'></td>
-         </form>
-      
-        </tr>
-      </tbody>
-    </table>
+
+  <div class='card'>
+    <div class='card-body'>
+      <h5 class="card-title">Upload Indici e Documenti</h5>
+      <form name='upload' method='post' enctype='multipart/form-data'>
+        {% csrf_token %}
+
+        <table class='table table-striped table-hover'>
+          <tbody>
+            <tr>
+              <td><label for='indice'>Indice Utenti:&nbsp;</label>
+                <input type='file' class="btn btn-primary" name='indice' id='indice' value='{{ uf.indice }}' accept='text/csv'></td>
+
+              <td><label for='descrizione'>Descrizione:&nbsp;</label>
+                  <input type='text' name='descrizione' id='descrizione' value=''>
+                  <input type='file' class="btn btn-primary" name='allegati' id='allegati' value='{{ uf.allegati }}' accept='application/pdf' multiple></td>
+            </tr>
+          </table>
+          <table>
+            <tr>
+              <td><input type='submit' class="btn btn-primary" value='Inserisci'><td>
+              <td><input type='submit' class="btn btn-primary" name='ritorna' value='Ritorna'></td>
+            </tr>
+          </table>
+        </tbody>
+      </form>
+    </div>
+  </div>
 
   <div><br><br></div>
 

+ 7 - 4
documento/views.py

@@ -64,9 +64,12 @@ def welcome(request):
       print('Richiesta cancellazione Documento',request.POST)
       documento = request.POST['DeleteDocument']  # perche' lo considera una lista e non un singolo valore?
       print('richiesta cancellazione documento:',documento)
-      d = Documento.objects.get(pk=documento)
-      delete_file(d)  #rimozione fisica del documento 
-      d.delete()
+      try:
+        d = Documento.objects.get(pk=documento)
+        delete_file(d)  #rimozione fisica del documento 
+        d.delete()
+      except Documento.DoesNotExist as dne:
+        print('il documento non esiste')
 
     filecaricati = AdminUpload(request.POST,request.FILES)
 
@@ -88,7 +91,7 @@ def welcome(request):
         data['listaok'] = listaok
         data['listanotok'] = listanotok
 
-  ElencoDocumentiPerAzienda = Documento.objects.filter(azienda=azienda).order_by("utente__nome")
+  ElencoDocumentiPerAzienda = Documento.objects.filter(azienda=azienda).order_by("utente__nome","documento")
   data['ElencoDocumentiPerAzienda'] = ElencoDocumentiPerAzienda
   print("Numero documenti associati",len(ElencoDocumentiPerAzienda))
 

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