From 0fd92220550ebaccf33c55e51c726499746c14b4 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Mon, 28 Mar 2022 21:32:16 +0200 Subject: [PATCH] Filter on last name and optionally on first name for Hello Asso Signed-off-by: Yohann D'ANELLO --- .../participation/management/commands/check_hello_asso.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/apps/participation/management/commands/check_hello_asso.py b/apps/participation/management/commands/check_hello_asso.py index 5be4fbe..bb877d9 100644 --- a/apps/participation/management/commands/check_hello_asso.py +++ b/apps/participation/management/commands/check_hello_asso.py @@ -44,9 +44,15 @@ class Command(BaseCommand): payer = payment["payer"] email = payer["email"] + last_name = payer["lastName"] + first_name = payer["firstName"] qs = User.objects.filter(email=email) if not qs.exists(): - self.stderr.write(f"Warning: a payment was found by the email address {email}, " + qs = User.objects.filter(last_name__icontains=last_name) + if qs.count() >= 2: + qs = qs.filter(first_name__icontains=first_name) + if not qs.exists(): + self.stderr.write(f"Warning: a payment was found by {first_name} {last_name} ({email}), " "but this user is unknown.") continue user = qs.get()