|
|
@@ -9,8 +9,9 @@ from django.template import engines, TemplateSyntaxError
|
|
|
from datetime import date
|
|
|
from uuid import uuid4,UUID
|
|
|
import json
|
|
|
-
|
|
|
+from datetime import datetim
|
|
|
import re
|
|
|
+
|
|
|
from django.db.models import Sum
|
|
|
#from .templatetags.commtags import *
|
|
|
from django.shortcuts import render
|
|
|
@@ -120,6 +121,7 @@ class ServizioMail:
|
|
|
|
|
|
if oggetto_render:
|
|
|
if self.debug: print('oggetto render',oggetto_render)
|
|
|
+ ora = datetime.now.strftime("%d/%m/%Y, %H:%M:%S")
|
|
|
|
|
|
for tt in self._to_complete:
|
|
|
ttl = [tt,]
|
|
|
@@ -140,6 +142,7 @@ def welcome(request):
|
|
|
punto di ingresso.
|
|
|
vengono mostrati tutti i modelli presenti presenti
|
|
|
'''
|
|
|
+ print('__name__',__name__,'welcome')
|
|
|
data = dict()
|
|
|
data['HeaderTitle'] = getConfig('HeaderTitle')
|
|
|
|
|
|
@@ -165,7 +168,7 @@ def welcome(request):
|
|
|
|
|
|
data['azienda'] = Azienda.objects.get(pk=data['AziendaId'])
|
|
|
data['comunicazione'] = data['azienda'].comunicazione_set.all()
|
|
|
- data['comm'] = data['azienda'].comm
|
|
|
+ #data['comm'] = data['azienda'].comm
|
|
|
print(data)
|
|
|
|
|
|
if request.method == "POST":
|
|
|
@@ -175,18 +178,79 @@ def welcome(request):
|
|
|
if 'Ritorna' in request.POST:
|
|
|
return HttpResponseRedirect(reverse("azienda:welcome"))
|
|
|
|
|
|
+ if 'Nuovo' in request.POST:
|
|
|
+ del request.session['ComId']
|
|
|
+ return HttpResponseRedirect(reverse("comunicazione:edit"))
|
|
|
+
|
|
|
+ if 'edit' in request.POST:
|
|
|
+ request.session['ComId'] = request.POST.get('edit')
|
|
|
+ print('ComId',request.session.get('ComId'))
|
|
|
+ return HttpResponseRedirect(reverse("comunicazione:edit"))
|
|
|
+
|
|
|
+ return render(request,'comunicazione.welcome.html',data)
|
|
|
+
|
|
|
+def edit(request):
|
|
|
+ print('__name__',__name__,'edit')
|
|
|
+ data = dict()
|
|
|
+ data['HeaderTitle'] = getConfig('HeaderTitle')
|
|
|
+
|
|
|
+ if not 'AziendaId' in request.session:
|
|
|
+ print('manca azienda')
|
|
|
+ return HttpResponseRedirect(reverse("login:start"))
|
|
|
+
|
|
|
+ data['AziendaId'] = request.session['AziendaId']
|
|
|
+ print("Azienda rilevata",data['AziendaId'])
|
|
|
+
|
|
|
+ data['azienda'] = Azienda.objects.get(pk=data['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"))
|
|
|
+
|
|
|
+ data['AdminId'] = request.session['AdminId']
|
|
|
+ print(data)
|
|
|
+
|
|
|
+ if 'UserId' in request.session:
|
|
|
+ data['UserId'] = request.session['UserId']
|
|
|
+
|
|
|
+ comunicazione = Comunicazione()
|
|
|
+
|
|
|
+ if 'ComId' in request.session:
|
|
|
+ ComId = request.session.get('ComId')
|
|
|
+ print('trovato ComId',ComId)
|
|
|
+ comunicazione = Comunicazione.objects.get(pk=ComId)
|
|
|
+
|
|
|
+ if request.method == 'POST':
|
|
|
+ print('richiesta effettuata')
|
|
|
+ if 'Ritorna' in request.POST:
|
|
|
+ return HttpResponseRedirect(reverse("comunicazione:welcome"))
|
|
|
+
|
|
|
fd = formDocumento(request.POST)
|
|
|
if fd.is_valid():
|
|
|
print('documento valido')
|
|
|
- else:
|
|
|
+ comunicazione.mittente = fd.cleaned_data.get('mittente')
|
|
|
+ comunicazione.soggetto = fd.cleaned_data.get('soggetto')
|
|
|
+ comunicazione.corpo = fd.cleaned_data.get('corpo')
|
|
|
+ comunicazione.azienda = data['azienda']
|
|
|
+ comunicazione.save()
|
|
|
+ else:
|
|
|
print('documento non valido')
|
|
|
- data['documento'] = formDocumento(request.POST)
|
|
|
-
|
|
|
+ data['documento'] = formDocumento(request.POST)
|
|
|
else:
|
|
|
- data['documento'] = formDocumento()
|
|
|
-
|
|
|
- return render(request,'comunicazione.welcome.html',data)
|
|
|
-
|
|
|
+ print('post non valido')
|
|
|
+ tmp = dict()
|
|
|
+ if len(data['azienda'].mail):
|
|
|
+ print('azienda contiene email',data['azienda'].mail)
|
|
|
+ tmp['mittente'] = data['azienda'].mail
|
|
|
+ else:
|
|
|
+ print('azienda non contiene email, prendo default',getConfig("DefaultEmail"))
|
|
|
+ tmp['mittente'] = getConfig("DefaultEmail")
|
|
|
+
|
|
|
+ tmp['soggetto'] = comunicazione.soggetto
|
|
|
+ tmp['corpo'] = comunicazione.corpo
|
|
|
+ data['documento'] = formDocumento(tmp)
|
|
|
+ print(data)
|
|
|
+ return render(request,'comunicazione.edit.html',data)
|
|
|
|
|
|
|
|
|
'''
|