From cbb9380c80ee00fbde64fa540398eb23e93aafcd Mon Sep 17 00:00:00 2001 From: Nicolas ROCHE Date: Thu, 26 Mar 2020 17:44:26 +0100 Subject: [PATCH] nanterre: correct address integrity checks (#41073) --- zoo/zoo_nanterre/utils.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/zoo/zoo_nanterre/utils.py b/zoo/zoo_nanterre/utils.py index a45e57b..a44a5cd 100644 --- a/zoo/zoo_nanterre/utils.py +++ b/zoo/zoo_nanterre/utils.py @@ -623,17 +623,20 @@ def integrity_check(): % (key, value)) for key, value in count_habite_rels.items(): - if key.content['statut_legal'] == 'majeur' and value < 1: - yield ("l'adulte %s n'a pas d'adresse" % key) - if key.content['statut_legal'] == 'majeur' and value > 1: yield ("l'adulte %s a plus d'une adresse: %s" % (key, value)) if key.content['statut_legal'] == 'mineur' and value > 2: yield ("l'enfant %s a plus de deux adresses: %s" % (key, value)) - if key.content['statut_legal'] == 'mineur' and value > 2: - yield ("l'enfant %s n'a pas d'adresse" % key) + id_having_address = [x[0].id for x in count_habite_rels.items()] + for key in Entity.objects.filter(schema__slug=INDIVIDU_ENT): + if key.id not in id_having_address: + if key.content['statut_legal'] == 'majeur': + yield ("l'adulte %s n'a pas d'adresse" % key) + + if key.content['statut_legal'] == 'mineur': + yield ("l'enfant %s n'a pas d'adresse" % key) def upper_dict(d):