From 59487f5627f5607776425dfcb1f52b324f235835 Mon Sep 17 00:00:00 2001 From: Henrik Levkowetz Date: Tue, 9 Jun 2020 19:42:11 +0000 Subject: [PATCH] Fixed an issue with multiple objects matching a registsration record fetched from the registration system (this has been caused by not correctly detecting changes in registration system details). - Legacy-Id: 17953 --- ietf/stats/utils.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/ietf/stats/utils.py b/ietf/stats/utils.py index 727dc8a78..47c1dd976 100644 --- a/ietf/stats/utils.py +++ b/ietf/stats/utils.py @@ -247,15 +247,19 @@ def get_meeting_registration_data(meeting): affiliation = registration['Company'].strip() country_code = registration['Country'].strip() address = registration['Email'].strip() - object, created = MeetingRegistration.objects.get_or_create( - meeting_id=meeting.pk, - email=address, - ) - object.first_name=first_name[:200] - object.last_name=last_name[:200] - object.affiliation=affiliation - object.country_code=country_code - object.save() + matching = MeetingRegistration.objects.filter(meeting_id=meeting.pk, email=address) + if matching.exists(): + object = matching.first() + created = False + else: + object = MeetingRegistration.objects.create(meeting_id=meeting.pk, email=address) + object.first_name=first_name[:200] + object.last_name=last_name[:200] + object.affiliation=affiliation + object.country_code=country_code + object.attended = True + object.save() + created = True # Add a Person object to MeetingRegistration object # if valid email is available