From da7aa42251143f358157b58507b7b6cc9f6eb7c1 Mon Sep 17 00:00:00 2001 From: Tanner Collin Date: Sun, 16 Feb 2020 02:35:31 +0000 Subject: [PATCH] Check old emails against current portal --- apiserver/apiserver/api/utils.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/apiserver/apiserver/api/utils.py b/apiserver/apiserver/api/utils.py index a3b0e29..16feca1 100644 --- a/apiserver/apiserver/api/utils.py +++ b/apiserver/apiserver/api/utils.py @@ -217,14 +217,12 @@ def link_old_member(data, user): if not old_models: raise ValidationError(dict(email='Unable to link, old DB wasn\'t imported.')) - old_members = old_models.Members.objects.using('old_portal') - try: - old_member = old_members.get(email=data['email']) - except old_models.Members.DoesNotExist: + member = models.Member.objects.get(old_email=data['email']) + except models.Member.DoesNotExist: raise ValidationError(dict(email='Unable to find email in old portal.')) - - member = models.Member.objects.get(id=old_member.id) + except models.Member.MultipleObjectsReturned: + raise ValidationError(dict(email='Duplicate emails found. Talk to Tanner.')) if member.user: raise ValidationError(dict(email='Old member already claimed.'))