Jelajahi Sumber

aggiornate le regole per la gestione del PVT, magari c'e' ancora qualcosa da affinare

Mauro 3 bulan lalu
induk
melakukan
4b942f1172
3 mengubah file dengan 26 tambahan dan 2 penghapusan
  1. 2 2
      documento/templates/documento.welcome.lista.html
  2. 1 0
      documento/views.py
  3. 23 0
      utente/views.py

+ 2 - 2
documento/templates/documento.welcome.lista.html

@@ -28,8 +28,8 @@
 		                                                <button name='carDW' type="submit" class="btn btn-outline-primary btn-sm">&#x2193;</button>
 		                                                <button name="carUP" type="submit" class="btn btn-outline-primary btn-sm">&#x2191;</button></th>
 	</form>
-	<th scope='col' style='white-space: nowrap; width:1%'>Pvt</th> 
         {% if 'DOCUMENTO.EDIT' in permesso %}
+	<th scope='col' style='white-space: nowrap; width:1%'>Pvt</th> 
         <th scope='col'>Elimina</th> 
         {% endif %}
 	<th scope='col'><input class="form-check-input" type="checkbox" id="selectAll" name="selectAll" value='0' onClick="toggle(this);"/></th>
@@ -46,12 +46,12 @@
 	  {% endif %}
 	  <td>{{ documento.documento }}<br>{{ documento.descrizione }} </td>
           <td>{{ documento.dataupload | date:'d/m/Y' }} </td>
+          {% if 'DOCUMENTO.EDIT' in permesso %}
 	  <td>{% if documento.privato %}
                 <button type='button' class='btn btn-primary btn-sm' data-bs-toggle='modal' data-bs-target='#UnsetPrivateModal{{ documento.id }}' value='{{ documento.id }}'>Pvt</button>
               {% else %}
                 <button type='button' class='btn btn-secondary btn-sm' data-bs-toggle='modal' data-bs-target='#SetPrivateModal{{ documento.id }}' value='{{ documento.id }}'>Pub</button>
               {% endif %}</td>
-            {% if 'DOCUMENTO.EDIT' in permesso %}
             <td><button type='button' class='btn btn-primary btn-sm' data-bs-toggle='modal' data-bs-target='#ConfirmDeleteModal{{ documento.id }}' value='{{ documento.id }}'>Elimina</button></td>
             {% endif %}
   	  <td><input class="form-check-input" type="checkbox" form="ElencoDocumenti" id="select-{{ documento.id }}" name="MultipleDocumentSelect" value='{{ documento.id }}'/></td>

+ 1 - 0
documento/views.py

@@ -300,6 +300,7 @@ def welcome(request,utente=None):
   # filtro temporaneo, non mostra i documenti che iniziano per EMO
   #####
   tmp = list()
+  print('filtro temporaneo',data['permesso'])
   if not "DOCUMENTO.MOSTRA.PRIVATO" in data['permesso']:
     for ed in ElencoDocumenti:
        if "emo_" not in ed.documento.lower() and not ed.privato:

+ 23 - 0
utente/views.py

@@ -263,6 +263,29 @@ def edit(request):
       return HttpResponseRedirect(reverse("utente:welcome"))    
     print('request.method x edit utente')
 
+    if 'SetPrivateDocument' in request.POST and request.POST.get('SetPrivateDocument'):
+      print('Richiesta setPrivate',request.POST)
+      documento = request.POST['SetPrivateDocument']  # perche' lo considera una lista e non un singolo valore?
+      print('richiesta SetPrivateDocument documento:',documento)
+
+      try: 
+        d = Documento.objects.get(pk=documento)
+        d.privato = True
+        d.save()
+      except Documento.DoesNotExist as dne:
+        print('il documento non esiste')
+
+    if 'UnsetPrivateDocument' in request.POST and request.POST.get('UnsetPrivateDocument'):
+      print('Richiesta UnsetPrivate',request.POST)
+      documento = request.POST['UnsetPrivateDocument']  # perche' lo considera una lista e non un singolo valore?
+      print('richiesta UnsetPrivateDocument documento:',documento)
+      try:
+        d = Documento.objects.get(pk=documento)
+        d.privato = False
+        d.save()
+      except Documento.DoesNotExist as dne:
+        print('il documento non esiste')
+	
     if 'DeleteDocument' in request.POST:
       documento = request.POST['DeleteDocument']
       print('documento da rimuovere',documento)