summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrédéric Péters <fpeters@entrouvert.com>2016-03-29 15:54:30 (GMT)
committerFrédéric Péters <fpeters@entrouvert.com>2016-03-29 15:55:54 (GMT)
commit17fc10f424deb0fb689acdda7983a383bdffdd21 (patch)
treeb6fed37f09c240f01113fe814ecc99763ab1853e
parent1a381d652d5d0fe88efb01e4b51be0c608efd5a2 (diff)
downloadwelco-0.27.zip
welco-0.27.tar.gz
welco-0.27.tar.bz2
alfortville: only warn about mails that were validated by the DGAv0.27
-rw-r--r--welco/contrib/alfortville/management/commands/send-avis-email.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/welco/contrib/alfortville/management/commands/send-avis-email.py b/welco/contrib/alfortville/management/commands/send-avis-email.py
index 3bb2493..6209197 100644
--- a/welco/contrib/alfortville/management/commands/send-avis-email.py
+++ b/welco/contrib/alfortville/management/commands/send-avis-email.py
@@ -16,12 +16,14 @@
from django.conf import settings
from django.contrib.auth import get_user_model
+from django.contrib.contenttypes.models import ContentType
from django.core.mail import EmailMessage, send_mass_mail
from django.core.management.base import BaseCommand, CommandError
from django.template.loader import render_to_string
from hobo.agent.common.models import Role
from welco.contrib.alfortville.models import Inbox
+from welco.sources.mail.models import Mail
class Command(BaseCommand):
@@ -33,11 +35,16 @@ class Command(BaseCommand):
message = render_to_string(['alfortville/avis-email_body.txt'], ctx)
mails = []
+ relevant_mails = Mail.objects.filter(status='done-dga')
+ content_type = ContentType.objects.get_for_model(Mail)
+
User = get_user_model()
for user in User.objects.all():
user_roles = [x.uuid for x in Role.objects.filter(user=user)]
avis = Inbox.objects.filter(
role_slug__in=user_roles,
+ source_type=content_type,
+ source_pk__in=[x.id for x in relevant_mails],
subtype__in=[Inbox.MANDATORY_AVIS, Inbox.AVIS],
done=False)
if avis.count() == 0: