From a70c6d478bf26c19fc971167df5ab13484ef580f Mon Sep 17 00:00:00 2001 From: Henrik Levkowetz Date: Sat, 29 Jun 2019 00:02:30 +0000 Subject: [PATCH] A fix for an issue in get_meeting_registration_data() which could happen if we tried to create a Person record for with a user of an existing Person. - Legacy-Id: 16331 --- ietf/stats/utils.py | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/ietf/stats/utils.py b/ietf/stats/utils.py index 4b70dcbb2..1a2f5d971 100644 --- a/ietf/stats/utils.py +++ b/ietf/stats/utils.py @@ -1,3 +1,6 @@ +# Copyright The IETF Trust 2017-2019, All Rights Reserved +# -*- coding: utf-8 -*- + import re import requests from collections import defaultdict @@ -288,16 +291,19 @@ def get_meeting_registration_data(meeting): email=address, ) - aliases = Alias.objects.filter(name=regname) - if aliases.exists(): - person = aliases.first().person - else: - # Create the new Person object. - person = Person.objects.create( - name=regname, - ascii=ascii_name, - user=user, - ) + try: + person = user.person + except Person.DoesNotExist: + aliases = Alias.objects.filter(name=regname) + if aliases.exists(): + person = aliases.first().person + else: + # Create the new Person object. + person = Person.objects.create( + name=regname, + ascii=ascii_name, + user=user, + ) # Create an associated Email address for this Person try: