Check old emails against current portal

This commit is contained in:
Tanner Collin 2020-02-16 02:35:31 +00:00
parent 3400f80f42
commit da7aa42251

View File

@ -217,14 +217,12 @@ def link_old_member(data, user):
if not old_models: if not old_models:
raise ValidationError(dict(email='Unable to link, old DB wasn\'t imported.')) raise ValidationError(dict(email='Unable to link, old DB wasn\'t imported.'))
old_members = old_models.Members.objects.using('old_portal')
try: try:
old_member = old_members.get(email=data['email']) member = models.Member.objects.get(old_email=data['email'])
except old_models.Members.DoesNotExist: except models.Member.DoesNotExist:
raise ValidationError(dict(email='Unable to find email in old portal.')) raise ValidationError(dict(email='Unable to find email in old portal.'))
except models.Member.MultipleObjectsReturned:
member = models.Member.objects.get(id=old_member.id) raise ValidationError(dict(email='Duplicate emails found. Talk to Tanner.'))
if member.user: if member.user:
raise ValidationError(dict(email='Old member already claimed.')) raise ValidationError(dict(email='Old member already claimed.'))