Ver código fonte

lavorazione su comunicazione

mauro 1 ano atrás
pai
commit
f85ae0ca50

+ 19 - 0
att/migrations/0012_alter_attivita_data.py

@@ -0,0 +1,19 @@
+# Generated by Django 5.1.1 on 2024-09-19 08:53
+
+import datetime
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('att', '0011_alter_attivita_data'),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name='attivita',
+            name='data',
+            field=models.DateTimeField(default=datetime.datetime(2024, 9, 19, 10, 53, 47, 771227)),
+        ),
+    ]

+ 13 - 1
att/views.py

@@ -39,9 +39,15 @@ def setLog(causale,azienda=None,amministratore=None,utente=None,documento=None):
   if utente:
     print('utente',utente.id,utente.nome)
     attivita.utente_id = utente.id
+    attivita.azienda = utente.azienda
 
   if documento:
-    attivita.documento_id = documento.id
+    attivita.documento = documento
+    attivita.utente = documento.utente
+    attivita.azienda = attivita.utente.azienda
+
+  if amministratore:
+    attivita.amministratore = amministratore
 
   attivita.data = timezone.now()
 
@@ -59,3 +65,9 @@ def getLogxAmministrazione(amministratore):
 def getLogxDocumento(documento):
   return Documento.attivita_set.all().order_by('-data')[:10]
 
+def getLogxAzienda(azienda):
+  #attivita = Azienda.attivita_set.all().order_by('-data')
+  attivita = Attivita.objects.filter(azienda_id = azienda).order_by('-data')
+  print('elenco delle attivita registrate x azienda',len(attivita))
+  return attivita
+

+ 59 - 25
azienda/templates/azienda.welcome.html

@@ -17,6 +17,12 @@
 	  <td> {{ az.partitaita }}</td>
           <td><button type="submit" class='btn btn-primary' name="utenti" value="{{ az.id }}">Utenti</button>
               <button type='submit' class="btn btn-primary" name="documenti" value='{{ az.id }}'>Documenti</button>
+	      {% if listaAttivitaxAzienda %}
+	        <button type 'submit' class='btn btn-primary' name="xx" value='{{ az.id }}'>Attività proprie</button>
+	      {% else %}
+                <button type='submit' class='btn btn-primary' name="attivita" value='{{ az.id }}'>Tutte le Attività</button>
+	      {% endif %}
+	      <button type='submit' class='btn btn-primary' name='comunicazioni' value='{{ az.id }}'>Comunicazioni</button>
          </td>
 
 	</tr>
@@ -32,33 +38,61 @@
 {% block bodybottom %}
     <div><br><br></div>
     <div class='form-outline mb-3 text-center btn-primary h3'>
-           Elenco Azioni Registrate
+      {% if listaAttivitaxAzienda %}
+           Elenco di tutte le attività registrate per l'azienda ...
+      {% else %}
+           Elenco attivita' registrate sul proprio account
+      {% endif %}
     </div>
 
     <div>
-    <table class='table table-striped table-hover'>
-      <thead class='thead-dark'>
-      <tr>
-        <th scope='col'>Data</th>
-        <th scope='col'>Causale</th>
-        <th scope='col'>Utente</th>
-        <th scope='col'>Amministratore</th>
-        <th scope='col'>documento</th>
-
-      </tr>
-      </thead>
-      <tbody>
-        {% for attivita in listaAttivita %}
-        <tr>
-          <td> {{ attivita.data | date:'d/m/Y H:i' }} </td>
-          <td> {{ attivita.causale.nome }} </td>
-          <td> {{ attivita.utente.nome }} </td>
-          <td> {{ attivita.amministratore.username }}</td>
-          <td> {{ attivita.documento.documento }}</td>
-        </tr>
-        {% endfor %}
-      </tbody>
-    </table>
-
+      {% if listaAttivitaxAzienda %}
+        <table class='table table-striped table-hover'>
+          <thead class='thead-dark'>
+          <tr>
+            <th scope='col'>Data</th>
+            <th scope='col'>Causale</th>
+            <th scope='col'>Utente</th>
+            <th scope='col'>Amministratore</th>
+            <th scope='col'>documento</th>
+          </tr>
+          </thead>
+          <tbody>
+            {% for attivita in listaAttivitaxAzienda %}
+              <tr>
+                <td> {{ attivita.data | date:'d/m/Y H:i' }} </td>
+                <td> {{ attivita.causale.nome }} </td>
+                <td> {{ attivita.utente.nome }} </td>
+                <td> {{ attivita.amministratore.username }}</td>
+                <td> {{ attivita.documento.documento }}</td>
+              </tr>
+            {% endfor %}
+          </tbody>
+        </table>
+      {% else %}
+        <table class='table table-striped table-hover'>
+          <thead class='thead-dark'>
+          <tr>
+            <th scope='col'>Data</th>
+            <th scope='col'>Causale</th>
+            <th scope='col'>Utente</th>
+            <th scope='col'>Amministratore</th>
+            <th scope='col'>documento</th>
+          </tr>
+          </thead>
+          <tbody>
+            {% for attivita in listaAttivitaxAmministrazione %}
+              <tr>
+                <td> {{ attivita.data | date:'d/m/Y H:i' }} </td>
+                <td> {{ attivita.causale.nome }} </td>
+                <td> {{ attivita.utente.nome }} </td>
+                <td> {{ attivita.amministratore.username }}</td>
+                <td> {{ attivita.documento.documento }}</td>
+              </tr>
+            {% endfor %}
+          </tbody>
+        </table>
+      {% endif %}
+    </div>
 {% endblock %}
 

+ 15 - 1
azienda/views.py

@@ -21,10 +21,11 @@ def welcome(request):
   for ax in a:
     tmplist.append(ax.azienda)
 
-  data['listaAttivita']=getLogxAmministrazione(u)
+  data['listaAttivitaxAmministrazione']=getLogxAmministrazione(u)
 
   if request.method=="POST":
 
+    print(request.POST)
     if 'ritorna' in request.POST:
       print('premuto tast ritorno,logout')
       return HttpResponseRedirect(reverse("login:start"))
@@ -45,6 +46,19 @@ def welcome(request):
       request.session['AziendaId'] = azienda
       return HttpResponseRedirect(reverse('documento:welcome'))
 
+    if "attivita" in request.POST:
+      print('premuto tasto attivita')
+      a = request.POST['attivita']
+      azienda = Azienda.objects.get(pk = a)
+      print('azienda x documenti',azienda.nome)
+      data['listaAttivitaxAzienda']=getLogxAzienda(azienda)
+
+    if 'comunicazioni' in request.POST:
+      print('premuto tasto comunicazioni')
+      a = request.POST['comunicazioni']
+      azienda = Azienda.objects.get(pk = a)
+      print('azienda x comunicazioni',azienda.nome)
+      return HttpResponseRedirect(reverse('comunicazione:welcome'))
 
   data['azienda'] = tmplist
   return render(request,'azienda.welcome.html',data)

+ 0 - 0
comunicazione/__init__.py


+ 7 - 0
comunicazione/admin.py

@@ -0,0 +1,7 @@
+from django.contrib import admin
+
+from .models import *
+
+admin.register(Comunicazione)
+class ComunicazioneAdmin(admin.ModelAdmin):
+  list_display = ['indice','valore','nota',]

+ 6 - 0
comunicazione/apps.py

@@ -0,0 +1,6 @@
+from django.apps import AppConfig
+
+
+class Comunicazione(AppConfig):
+    name = 'comunicazione'
+    default_auto_field = 'django.db.models.BigAutoField'

+ 28 - 0
comunicazione/migrations/0001_initial.py

@@ -0,0 +1,28 @@
+# Generated by Django 5.0.7 on 2024-08-11 09:30
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    initial = True
+
+    dependencies = [
+    ]
+
+    operations = [
+        migrations.CreateModel(
+            name='Comunicazione',
+            fields=[
+                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+                ('indice', models.CharField(max_length=32)),
+                ('valore', models.CharField(max_length=128, null=True)),
+                ('nota', models.CharField(max_length=256, null=True)),
+            ],
+            options={
+                'db_table': 'Comunicazione',
+                'ordering': ['indice'],
+                'managed': False,
+            },
+        ),
+    ]

+ 17 - 0
comunicazione/migrations/0002_alter_comunicazione_options.py

@@ -0,0 +1,17 @@
+# Generated by Django 5.1.1 on 2024-09-17 18:17
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('comunicazione', '0001_initial'),
+    ]
+
+    operations = [
+        migrations.AlterModelOptions(
+            name='comunicazione',
+            options={'managed': False, 'ordering': ['soggetto']},
+        ),
+    ]

+ 0 - 0
comunicazione/migrations/__init__.py


+ 18 - 0
comunicazione/models.py

@@ -0,0 +1,18 @@
+from django.db import models
+
+from azienda.models import *
+
+class Comunicazione(models.Model):
+  '''
+  contiene i valori di configurazione della posta
+  '''
+  mittente = models.CharField(max_length=256,null=True)
+  soggetto = models.CharField(max_length=256,null=True)
+  corpo = models.CharField(max_length=2048,null=True)
+  azienda = models.ForeignKey(Azienda,default=0,on_delete=models.CASCADE)
+  class Meta:
+    ordering = ['soggetto']
+    db_table = 'Comunicazione'
+    managed  = False
+    constraints = [ models.UniqueConstraint(fields=['soggetto'], name="unique-comunicazionesoggetto") ]
+    indexes = [ models.Index(fields=['soggetto']) ]

+ 33 - 0
comunicazione/templates/comunicazione.welcome.html

@@ -0,0 +1,33 @@
+{% extends 'base.html' %}
+
+{% block body %}
+  <form name="comunicazione" method="POST">
+  <table class='table table-striped table-hover'>
+    <thead class='thead-dark'>
+      <tr>
+        <th scope='col'>From</th>
+        <th scope='col'>Soggetto</th>
+      </tr>
+    </thead>
+    <tbody>
+      {% csrf_token %}
+      {% for az in comunicazione %}
+        <tr>
+	  <td> {{ az.from }} </td>
+	  <td> {{ az.soggetto }}</td>
+          <td><button type="submit" class='btn btn-primary' name="utenti" value="{{ az.id }}">Edit</button></td>
+	</tr>
+      {% endfor %} 
+    </tbody>
+  </table>
+    <div>
+      <input type='submit' class='btn btn-primary' name='nuovo' value='nuovo'>
+      <input type='reset' class='btn btn-primary' name='reset' value='reset'>
+      <input type='submit' class="btn btn-primary" name="ritorna" value="Ritorna">
+    </td>
+  </form>
+{% endblock %}
+
+{% block bodybottom %}
+{% endblock %}
+

+ 3 - 0
comunicazione/tests.py

@@ -0,0 +1,3 @@
+from django.test import TestCase
+
+# Create your tests here.

+ 8 - 0
comunicazione/urls.py

@@ -0,0 +1,8 @@
+from django.urls import path
+from . import views
+
+app_name='comunicazione'
+urlpatterns = [
+  path('welcome',views.welcome,name='welcome'),
+  ]
+

+ 222 - 0
comunicazione/views.py

@@ -0,0 +1,222 @@
+from django.shortcuts import render
+from django.core.mail import send_mail
+from django.core.mail import SafeMIMEText
+
+from django.core.mail import EmailMultiAlternatives
+from django.template.loader import get_template
+from django.template import Context
+from django.template import engines, TemplateSyntaxError
+from datetime import date
+from uuid import uuid4,UUID
+import json
+
+import re
+from django.db.models import Sum
+#from .templatetags.commtags import *
+from django.shortcuts import render
+
+from .models import *
+from config.views import *
+from azienda.views import *
+from utente.views import *
+from documento.views import *
+
+def template_from_string(template_string, using=None):
+
+  """
+  Convert a string into a template object,
+  using a given template engine or using the default backends 
+  from settings.TEMPLATES if no engine was specified.
+  This function is based on django.template.loader.get_template, 
+  but uses Engine.from_string instead of Engine.get_template.
+  """
+
+  chain = []
+  engine_list = engines.all() if using is None else [engines[using]]
+  for engine in engine_list:
+    try:
+      return engine.from_string(template_string)
+    except TemplateSyntaxError as e:
+      chain.append(e)
+  raise TemplateSyntaxError(template_string, chain=chain)
+
+class ServizioMail:
+  def __init__(self,debug=False):
+    self._from_ = getConfigurazione('default_mail_from')
+    self._to_ = []
+    self._to = {}
+    self.debug = debug
+    self.soggetto = ""
+    self.corpo_testo = ""
+    self.corpo_html = ""
+    self.set_data()
+    self.json = None
+
+  def set_mailfrom(self,mail_from):
+    self._from_ = mail_from
+    if self.debug: print('mail_from',self._from_)
+
+  def set_listadestinatari(self,lista=[]):
+    self._to_ = []
+    self.add_listadestinatari(lista)
+    if self.debug: print('lista destinatari',self._to_)
+
+  def set_rcptto(self,lista=[]):
+    self.set_listadestinatari(lista)
+
+  def add_listadestinatari(self,mail=None):
+    if self.debug: print('type mail:',type(mail))
+    if mail:
+      if type(mail) == list:
+        for i in mail:
+          self._to_.append(i)
+        return
+      self._to_.append((mail))
+      if self.debug: print('lista destinatari',self._to_)
+
+  def add_to(self,mail=None):
+    self.add_listadestinatari(mail)
+
+  def set_soggetto(self,soggetto=""):
+    self.soggetto = soggetto
+
+  def set_oggetto(self,oggetto="",html=False):
+    self.oggetto = oggetto
+    if self.debug: print('set_oggetto html:',html)
+    self.html = html
+
+  def set_data(self,data={}):
+    self.data = data
+    #print('data',self.data)
+
+  def set_json(self,data={}):
+    self.json = json.dumps(data)
+    if self.debug:  print('json:',self.json)
+  def send(self):
+
+    # normalizza i destinatari (uno solo, non ripetuti)
+    if self.debug: print('self._to_',self._to_)
+
+    for i in self._to_:
+      self._to[i] = i
+ 
+    self._to_complete = [ x for x in self._to.values() ]
+    if self.debug: print("destinatari:",self._to_complete)
+ 
+    #rendering del soggetto
+    soggetto = template_from_string(self.soggetto)
+    soggetto_render = soggetto.render(self.data)
+    if self.debug: print("soggetto",soggetto)
+
+    oggetto = template_from_string(self.oggetto)
+    oggetto_render = None
+    try:
+      oggetto_render = oggetto.render(self.data)
+    except TemplateSyntaxError as tse:
+      print('Errore nel Template')
+      print(tse)
+
+    if oggetto_render:
+      if self.debug: print('oggetto render',oggetto_render)
+
+      for tt in self._to_complete:
+        ttl = [tt,]
+        msg = None
+        if self.debug: print('richiesta html::',self.html)
+        if self.html: 
+          msg=EmailMultiAlternatives(soggetto_render, oggetto_render, self._from_, ttl)
+          msg.attach_alternative(oggetto_render, "text/html")
+        else: msg=EmailMultiAlternatives(soggetto_render, oggetto_render, self._from_, ttl)
+
+        if self.json:
+          msg.attach_alternative(self.json,'text/json')
+
+        msg.send()
+
+def welcome(request):
+  '''
+  punto di ingresso.
+  vengono mostrati tutti i modelli presenti presenti
+  '''
+
+  data = dict()
+  data['HeaderTitle'] = getConfig('HeaderTitle')
+
+  if not 'AziendaId' in request.session:
+    print('manca azienda')
+    return HttpResponseRedirect(reverse("login:start"))
+  else:
+    data['AziendaId'] = request.session['AziendaId']
+
+  if not 'AdminId' in request.session or 'UserId' in request.session:
+    print("Non rilevo presensa UserId e AdminId in request.session")
+    return HttpResponseRedirect(reverse("login:start"))
+
+  if 'AdminId' in request.session:
+    data['AdminId'] = request.session['AdminId']
+
+  if 'UserId' in request.session:
+    data['UserId'] = request.session['UserId']
+
+  #filtro:
+  # selezionare tutti gli utenti per AziendaId
+  data['admin'] = User.objects.get(pk=data['AdminId'])
+
+  data['azienda'] = Azienda.objects.get(pk=data['AziendaId'])
+  data['comunicazione'] = data['azienda'].comunicazione_set.all()
+  print(data)
+
+  '''
+  #filtro:
+  # selezionare tutti gli utenti per AziendaId
+  admin = User.objects.get(pk=data['AdminId'])
+  data['admin'] = admin
+  azienda = Azienda.objects.get(pk=data['AziendaId'])
+  data['azienda'] = azienda
+  utenti = Utente.objects.filter(azienda = azienda)
+  data['utenti'] = utenti
+
+  if request.method == 'POST':
+
+    if 'ritorna' in request.POST:
+      return HttpResponseRedirect(reverse("azienda:welcome"))
+
+    if 'DeleteDocument' in request.POST:
+      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)
+      try:
+        d = Documento.objects.get(pk=documento)
+        delete_file(d)  #rimozione fisica del documento
+        setLog(5,documento,admin)
+        d.delete()
+      except Documento.DoesNotExist as dne:
+        print('il documento non esiste')
+
+    filecaricati = AdminUpload(request.POST,request.FILES)
+
+    if filecaricati.is_valid():
+
+      print('record filecaricati validi')
+      if 'indice' in filecaricati.cleaned_data and filecaricati.cleaned_data.get('indice'):
+        fileindice = filecaricati.cleaned_data.get('indice')
+        print('presente file indice',fileindice)
+        save_and_load_file_indice(request,fileindice,azienda)
+
+      if 'allegati' in filecaricati.cleaned_data and filecaricati.cleaned_data.get('allegati'):
+        print('presenti documenti da allegare')
+        listadocumenti = filecaricati.cleaned_data['allegati']
+        print(listadocumenti)
+        print(type(azienda))
+        print(azienda.id)
+        listaok,listanotok = save_and_load_file_multiple(listadocumenti,request,utenti,azienda,filecaricati.cleaned_data['descrizione'])
+        data['listaok'] = listaok
+        data['listanotok'] = listanotok
+
+  ElencoDocumentiPerAzienda = Documento.objects.filter(azienda=azienda).order_by("utente__nome","documento")
+  data['ElencoDocumentiPerAzienda'] = ElencoDocumentiPerAzienda
+  print("Numero documenti associati",len(ElencoDocumentiPerAzienda))
+  '''
+
+  return render(request,'comunicazione.welcome.html',data)
+

+ 6 - 3
documento/managefile.py

@@ -6,6 +6,7 @@ from django.db import IntegrityError
 
 from .models import *
 from config.views import *
+from att.views import *
 
 from django.conf import  settings
 from django.conf.urls.static import static
@@ -125,7 +126,7 @@ def upload_file_indice(uploaded_file):
   return stored_file
 
 ##################################################################################
-def save_and_load_file_multiple(listadocumenti,request,utente,azienda,descrizione):
+def save_and_load_file_multiple(listadocumenti,request,utente,azienda,descrizione,amministratore):
   listaok = list()
   listanotok = list()
   for singolodocumento in listadocumenti:
@@ -143,6 +144,7 @@ def save_and_load_file_multiple(listadocumenti,request,utente,azienda,descrizion
         documento.descrizione = descrizione
         try:
           documento.save()
+          setLog(8,azienda=azienda,utente=utente,documento=documento,amministratore=amministratore)
           listaok.append(documento.documento)
         except IntegrityError as ie:
           print("problema di integrita', il file esiste",ie)
@@ -150,7 +152,7 @@ def save_and_load_file_multiple(listadocumenti,request,utente,azienda,descrizion
   print(listaok,listanotok)
   return (listaok,listanotok)
 
-def save_and_load_file_single(listadocumenti,request,utente,azienda,descrizione):
+def save_and_load_file_single(listadocumenti,request,utente,azienda,descrizione,amministratore):
   listaok = list()
   listanotok = list()
   for singolodocumento in listadocumenti:
@@ -165,8 +167,9 @@ def save_and_load_file_single(listadocumenti,request,utente,azienda,descrizione)
     documento.descrizione = descrizione
     try:
       documento.save()
+      setLog(8,azienda=azienda,utente=utente,documento=documento,amministratore=amministratore)
       listaok.append(documento.documento)
-    except IntegritiError as ie:
+    except IntegrityError as ie:
       print("problema di integrita', il file esiste",ie)
       listanotok.append(documento.documento)
   return (listaok,listanotok)

+ 4 - 4
documento/views.py

@@ -67,6 +67,7 @@ def welcome(request):
       try:
         d = Documento.objects.get(pk=documento)
         delete_file(d)  #rimozione fisica del documento 
+        setLog(5,documento,admin)
         d.delete()
       except Documento.DoesNotExist as dne:
         print('il documento non esiste')
@@ -148,9 +149,8 @@ def finalize_download(request,did,uid=None):
 
   mime_type, _ = mimetypes.guess_type(fl_completa)
   fl = fl_completa
-  print('fl',fl,mime_type)
-  response = FileResponse(open(fl,'rb'),content_type='application/pdf',as_attachment=False)
-  #response['Content-Disposition'] = "attachment; filename=%s" % documento.documento
-  setNewLog(3,{'utente':utente,'documento':documento,'azienda':utente.azienda})
+  print('fl',fl,mime_type,'fn',documento.documento)
+  response = FileResponse(open(fl,'rb'),content_type='application/pdf',filename="%s" % documento.documento,as_attachment=False)
+  setLog(3,utente=utente,documento=documento,azienda=utente.azienda)
   return response
 

+ 1 - 0
gd/urls.py

@@ -24,5 +24,6 @@ urlpatterns = [
     path('utente/',include('utente.urls')),
     path('azienda/',include('azienda.urls')),
     path('documento/',include('documento.urls')),
+    path('comunicazione/',include('comunicazione.urls')),
 ]
 

+ 75 - 61
utente/templates/utente.download.html

@@ -19,8 +19,12 @@
     <button class="nav-link" id="profile-tab" data-bs-toggle="tab" data-bs-target="#profile" type="button" role="tab" aria-controls="profile" aria-selected="false">Profilo</button>
   </li>
   <li class="nav-item" role="presentation">
-    <button class="nav-link" id="messages-tab" data-bs-toggle="tab" data-bs-target="#messages" type="button" role="tab" aria-controls="messages" aria-selected="false">Logging</button>
+    <button class="nav-link" id="messages-tab" data-bs-toggle="tab" data-bs-target="#messages" type="button" role="tab" aria-controls="messages" aria-selected="false">Attività</button>
+  <li>
+   <li class="nav-item" role="presentation">
+    <button class="nav-link" id="messages-tab" data-bs-toggle="tab" data-bs-target="#byebye" type="button" role="tab" aria-controls="byebye" aria-selected="false">Uscita</button>
   </li>
+ 
 </ul>
 <! -- end nav tabs -->
 
@@ -54,75 +58,85 @@
   </div>
 
   <div class="tab-pane" id="profile" role="tabpanel" aria-labelledby="profile-tab" tabindex="0">
-   <div><br><br></div>
-   <div class='form-outline mb-3 text-center btn-primary h3'>
+    <div><br><br></div>
+    <div class='form-outline mb-3 text-center btn-primary h3'>
            Profilo Personale
-   </div>
-    <form name='download' method='post' class='form-container card p-3 bg-light'>
-    {% csrf_token %}
-    <div class='form-outline mb-3'>
-      <label class='form-label' for='nome'>nome</label>
-      <input type='text' class='form-control' id='nome' name='nome' value='{{ utente.nome }}' readonly>
-    </div>
-    <div class='form-outline mb-3'>
-      <label class='form-label' for='cfisc'>nome</label>
-      <input type='text' class='form-control' id='cfisc' name='cfisc' value='{{ utente.codicefiscale }}' readonly>
-    </div>
-    <div class='form-outline mb-3'>
-      <label class='form-label' for='luogonascita'>Luogo di Nascita</label>
-      <input type='text' class='form-control' id='luogonascita' name='luogonascita' value='{{ utente.luogonascita }}' readonly>
-    </div>
-    <div class='form-outline mb-3'>
-      <label class='form-label' for='datanascita'>Data di Nascita</label>
-      <input type='text' class='form-control' id='datanascita' name='datanascita' value='{{ utente.datanascita }}' readonly>
-    </div>
-   <div class='form-outline mb-3'>
-      <label class='form-label' for='pin'>pin/Password</label>
-      <input type='text' class='form-control' id='pin' name='pin' value='{{ utente.pin }}'>
-    </div>
-    <div class='form-outline mb-3'>
-      <label class='form-label' for='mail'>Mail</label>
-      <input type='text' class='form-control' id='mail' name='mail' value='{{ utente.mail }}'>
     </div>
-    <div>
-    <input type='submit' class="btn btn-secondary" name='aggiorna' value='Aggiorna'/>
-    <input type='submit' class="btn btn-primary" name="ritorna" value="Logout">
-    </div>
-  </form>
-</div>
 
-  <div class="tab-pane" id="messages" role="tabpanel" aria-labelledby="messages-tab" tabindex="0">
-   <div><br><br></div>
+    <form name='download' method='post' class='form-container card p-3 bg-light'>
+      {% csrf_token %}
+      <div class='form-outline mb-3'>
+        <label class='form-label' for='nome'>nome</label>
+        <input type='text' class='form-control' id='nome' name='nome' value='{{ utente.nome }}' readonly>
+      </div>
+      <div class='form-outline mb-3'>
+        <label class='form-label' for='cfisc'>nome</label>
+        <input type='text' class='form-control' id='cfisc' name='cfisc' value='{{ utente.codicefiscale }}' readonly>
+      </div>
+      <div class='form-outline mb-3'>
+        <label class='form-label' for='luogonascita'>Luogo di Nascita</label>
+        <input type='text' class='form-control' id='luogonascita' name='luogonascita' value='{{ utente.luogonascita }}' readonly>
+      </div>
+      <div class='form-outline mb-3'>
+        <label class='form-label' for='datanascita'>Data di Nascita</label>
+        <input type='text' class='form-control' id='datanascita' name='datanascita' value='{{ utente.datanascita }}' readonly>
+      </div>
+     <div class='form-outline mb-3'>
+        <label class='form-label' for='pin'>pin/Password</label>
+        <input type='text' class='form-control' id='pin' name='pin' value='{{ utente.pin }}'>
+      </div>
+      <div class='form-outline mb-3'>
+        <label class='form-label' for='mail'>Mail</label>
+        <input type='text' class='form-control' id='mail' name='mail' value='{{ utente.mail }}'>
+      </div>
 
-   <div class='form-outline mb-3 text-center btn-primary h3'>
+      <div>
+        <input type='submit' class="btn btn-secondary" name='aggiorna' value='Aggiorna'/>
+        <input type='submit' class="btn btn-primary" name="ritorna" value="Logout">
+      </div>
+    </form>
+  </div>
+
+  <div class="tab-pane" id="messages" role="tabpanel" aria-labelledby="messages-tab" tabindex="0">
+    <div><br><br></div>
+    <div class='form-outline mb-3 text-center btn-primary h3'>
           Ultime attività registrate 
     </div>
     <div>
-    <table class='table table-striped table-hover mb-2'>
-      <thead class='thead-dark'>
-      <tr>
-        <th scope='col'>Data</th>
-        <th scope='col'>Causale</th>
-        <th scope='col'>Utente</th>
-        <th scope='col'>Amministratore</th>
-        <th scope='col'>documento</th>
-      </tr>
-      </thead>
-      <tbody>
-        {% for attivita in listaAttivita %}
-        <tr>
-          <td> {{ attivita.data | date:'d/m/Y H:i' }} </td>
-          <td> {{ attivita.causale.nome }} </td>
-          <td> {{ attivita.utente.nome }} </td>
-          <td> {{ attivita.amministratore.name }}</td>
-          <td> {{ attivita.documento.documento }}</td>
-        </tr>
-        {% endfor %}
-      </tbody>
-    </table>
+      <table class='table table-striped table-hover mb-2'>
+        <thead class='thead-dark'>
+          <tr>
+            <th scope='col'>Data</th>
+            <th scope='col'>Causale</th>
+            <th scope='col'>Utente</th>
+            <th scope='col'>Amministratore</th>
+            <th scope='col'>documento</th>
+          </tr>
+        </thead>
+        <tbody>
+          {% for attivita in listaAttivita %}
+            <tr>
+              <td> {{ attivita.data | date:'d/m/Y H:i' }} </td>
+              <td> {{ attivita.causale.nome }} </td>
+              <td> {{ attivita.utente.nome }} </td>
+              <td> {{ attivita.amministratore.name }}</td>
+              <td> {{ attivita.documento.documento }}</td>
+            </tr>
+          {% endfor %}
+        </tbody>
+      </table>
     </div>
   </div>
-  </div>
+
+  <div class="tab-pane" id="byebye" role="tabpanel" aria-labelledby="byebye-tab" tabindex="0">
+    <div><br><br></div>
+    <div class='form-outline mb-3 text-center btn-primary h3'>
+	    <a href="{% url 'login:start' %}">Fine Sessione</a>
+    </div>
+    <div class='form-outline mb-3 text-center btn-primary h3'>
+      Grazie per aver usato i nostri servizi
+    </div>
+  </div> 
 </div>
 
 

+ 12 - 9
utente/templates/utente.edit.document.html

@@ -59,15 +59,18 @@
    </table>
 
    <form name='fileManager' method="POST"  enctype='multipart/form-data'>
-     {% csrf_token %}
-     <div class='form-group'>
-     <input type='file' class="btn btn-primary form-control" name='allegati' id='allegati' value='{{ uf.allegati }}' accept='application/pdf' multiple>
-     </div>
-     <div class='form-group'>
-     <label  class='form-control-label' for='descrizione'>Descrizione:&nbsp;</label><input type='text' name='descrizione' id='descrizione' value=''>
-     </div>
-     <input class="btn btn-primary" type='submit' value='Inserisci'>
-   </form>
+      {% csrf_token %}
+
+      <table class='table table-striped table-hover'>
+          <tbody>
+            <tr>
+              <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 class="btn btn-primary" type='submit' value='Inserisci'></td>
+            </tr>
+          </table>
+      </form>
 
    {% if listaok %}
      <table class='table table-striped table-hover'>

+ 4 - 0
utente/templates/utente.edit.html

@@ -25,6 +25,10 @@
   <li class="nav-item" role="presentation">
     <button class="nav-link" id="logger-tab" data-bs-toggle="tab" data-bs-target="#logger-pane" type="button" role="tab" aria-controls="logger-pane" aria-selected="false">attivita</button>
   </li>
+  <li class="nav-item" role="presentation">
+	  <button class="nav-link" id="return-tab" data-bs-toggle="tab" data-bs-target="#return-pane" type="button" role="tab" aria-controls="return-pane" aria-selected="false"><a href="{% url 'utente:welcome' %}">Indietro</a></button>
+  </li>
+
 </ul>
 <!-- end nav tabs -->
 

+ 1 - 1
utente/templates/utente.edit.logger.html

@@ -21,7 +21,7 @@
          <td> {{ attivita.data | date:'d/m/Y H:i' }} </td>
          <td> {{ attivita.causale.nome }} </td>
          <td> {{ attivita.utente.nome }} </td>
-         <td> {{ attivita.amministratore.name }}</td>
+         <td> {{ attivita.amministratore.username }}</td>
          <td> {{ attivita.documento.documento }}</td>
        </tr>
        {% endfor %}

+ 5 - 5
utente/views.py

@@ -68,7 +68,7 @@ def welcome(request):
         print('presenti documenti da allegare')
         listadocumenti = filecaricati.cleaned_data['allegati']
         print(listadocumenti)
-        listaok,listanotok = save_and_load_file_multiple(listadocumenti,request,data['utenti'],data['AziendaId'],filecaricati.cleaned_data['descrizione'])
+        listaok,listanotok = save_and_load_file_multiple(listadocumenti,request,data['utenti'],data['AziendaId'],filecaricati.cleaned_data['descrizione'],data['admin'])
         data['listaok'] = listaok
         data['listanotok'] = listanotok
   return render(request,'utente.welcome.html',data)
@@ -145,8 +145,8 @@ def edit(request):
       utente.datanascita = fu.cleaned_data['datanascita']
       utente.mail = fu.cleaned_data['mail']
       utente.pin = fu.cleaned_data['pin']
-      print(fu.cleaned_data)
-      print(utente.id)
+      print('utente id',utente.id,utente.nome)
+      setLog(7,utente)
       utente.save()
     print('Form non valida')
     tmp = dict()
@@ -167,7 +167,7 @@ def edit(request):
         listadocumenti = filecaricati.cleaned_data['allegati']
         print(listadocumenti)
         print('descrizione',filecaricati.cleaned_data['descrizione'])
-        save_and_load_file_single(listadocumenti,request,utente,data['azienda'],filecaricati.cleaned_data['descrizione'])
+        save_and_load_file_single(listadocumenti,request,utente,data['azienda'],filecaricati.cleaned_data['descrizione'],data['admin'])
         data['documentiUtente'] = utente.documento_set.all()
   else:
     print('Request non valida,utente:',utente.id)
@@ -235,7 +235,7 @@ def download(request):
       utente.mail = pinmail.cleaned_data['mail']
       utente.save()
       print('utente aggiornato',utente.id)
-      setNewLog(6,{'utente':utente})
+      setLog(6,utente=utente)
 
   # verifica bonta' mail.
   regex = r'\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,7}\b'