Mauro 11 месяцев назад
Родитель
Сommit
be7aa66bcc

+ 0 - 1
documento/managefile.py

@@ -129,7 +129,6 @@ def associafile_a_utente(singolodocumento,request,utente,azienda,descrizione,amm
   documento = Documento()
   documento.dataupload = datetime.datetime.now()
   documento.utente = utente
-  documento.azienda = azienda
 
   if pertutti: 
     documento.documento = "".join((utente.codicefiscale.strip(),"_",singolodocumento.name))

+ 17 - 0
documento/migrations/0014_remove_documento_azienda.py

@@ -0,0 +1,17 @@
+# Generated by Django 5.1.2 on 2025-01-06 08:20
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('documento', '0013_remove_documento_documento_d_documen_a68d7b_idx'),
+    ]
+
+    operations = [
+        migrations.RemoveField(
+            model_name='documento',
+            name='azienda',
+        ),
+    ]

+ 4 - 1
utente/forms.py

@@ -13,7 +13,10 @@ class formUtente(forms.Form):
     self.fields['mail'] = forms.CharField(required=False)
     self.fields['CancellaUtente'] = forms.BooleanField(required=False)
     self.fields['pin'] = forms.CharField(required=True)
-    self.fields['primologin'] = forms.BooleanField(required=False)
+    self.fields['forzanuovapassword'] = forms.BooleanField(required=False)
+    self.fields['cambiopassword'] = forms.BooleanField(required=False)
+    self.fields['forzanuovapassword'] = forms.BooleanField(required=False)
+    self.fields['otppassword'] = forms.BooleanField(required=False)
     self.fields['sede'] = forms.IntegerField(required=False)
 
 class formPinMail(forms.Form):

+ 32 - 0
utente/migrations/0019_remove_utente_primologin_utente_cambiopassword_and_more.py

@@ -0,0 +1,32 @@
+# Generated by Django 5.1.2 on 2025-01-06 08:20
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('utente', '0018_utente_lostpin'),
+    ]
+
+    operations = [
+        migrations.RemoveField(
+            model_name='utente',
+            name='primologin',
+        ),
+        migrations.AddField(
+            model_name='utente',
+            name='cambiopassword',
+            field=models.BooleanField(default=False),
+        ),
+        migrations.AddField(
+            model_name='utente',
+            name='forzanuovapassword',
+            field=models.BooleanField(default=False),
+        ),
+        migrations.AddField(
+            model_name='utente',
+            name='otppassword',
+            field=models.BooleanField(default=False),
+        ),
+    ]

+ 4 - 1
utente/models.py

@@ -14,12 +14,15 @@ class Utente(models.Model):
     mail = models.CharField(max_length=128,null=False,default="")
     azienda = models.ForeignKey(Azienda,on_delete=models.PROTECT,null=True)
     sede = models.ForeignKey(Sede,on_delete=models.PROTECT,null=True)
-    primologin = models.BooleanField(null=False,default=1)
     daticompleti=models.BooleanField(null=False,default=0)
     pin = models.CharField(max_length=64,null=False,default="")
     encrypt=models.CharField(max_length=64,null=False,default="")
     uuid = models.CharField(max_length=32,null=False,default="")
     lostpin = models.BooleanField(null=False,default=False)
+    cambiopassword = models.BooleanField(null=False,default=False)
+    forzanuovapassword = models.BooleanField(null=False,default=False)
+    otppassword = models.BooleanField(null=False,default=False)
+
     @property
     def documenti(self):
       return len(self.documento_set.all())

+ 12 - 3
utente/views.py

@@ -165,7 +165,9 @@ def edit(request):
       utente.datanascita = fu.cleaned_data['datanascita']
       utente.mail = fu.cleaned_data['mail'].lower()
       utente.pin = fu.cleaned_data['pin']
-      utente.primologin = fu.cleaned_data['primologin']
+      utente.cambiopassword = fu.cleaned_data['cambiopassword']
+      utente.forzanuovapassword = fu.cleaned_data['forzanuovapassword']
+      utente.otppassword = fu.cleaned_data['otppassword']
       tmp_sede = fu.cleaned_data['sede']
       print('tmp_sede',tmp_sede)
       try:
@@ -176,6 +178,8 @@ def edit(request):
       print('utente da registrare',utente.nome,utente.sede_id)
       setLog(7,utente=utente)
       utente.save()
+      return HttpResponseRedirect(reverse("utente:welcome"))
+
     print('Form non valida')
     tmp = dict()
     tmp['nome'] = utente.nome
@@ -185,6 +189,9 @@ def edit(request):
     tmp['sede'] = utente.sede_id
     tmp['mail'] = utente.mail
     tmp['pin'] = utente.pin
+    tmp['cambiopassword'] = utente.cambiopassword
+    tmp['forzanuovapassword'] = utente.forzanuovapassword
+    tmp['otppassword'] = utente.otppassword
     print('utente.sede_id',utente.sede_id)
     tmp['sede'] = utente.sede_id
     print('tmp su form non valida',tmp)
@@ -209,7 +216,9 @@ def edit(request):
     tmp['luogonascita'] = utente.luogonascita
     tmp['mail'] = utente.mail
     tmp['pin'] = utente.pin
-    tmp['primologin'] = utente.primologin
+    tmp['forzanuovapassword'] = utente.forzanuovapassword
+    tmp['cambiopassword'] = utente.cambiopassword
+    tmp['otppassword'] = utente.otppassword
     tmp['sede'] = utente.sede_id
     print("tmp su request non valida",tmp)
     data['utente'] = formUtente(tmp)
@@ -424,7 +433,7 @@ def forceUpdatePassword(request,uuid):
         print('password vecchia ok')
         a.pin = pin1
         a.uuid = ""
-        a.primologin = False
+        a.forzanuovapassword = False
         a.lostpassword = False
         a.save()