Stop checking old_models.py on registration

This commit is contained in:
Tanner Collin 2020-09-13 20:09:59 +00:00
parent 5f08bd5e01
commit 164aa3c9c7

View File

@ -19,11 +19,6 @@ from django.core.cache import cache
from django.utils.timezone import now, pytz from django.utils.timezone import now, pytz
from . import models, serializers, utils_ldap from . import models, serializers, utils_ldap
try:
from . import old_models
except ImportError:
logger.info('Running without old portal data...')
old_models = None
STATIC_FOLDER = 'data/static/' STATIC_FOLDER = 'data/static/'
@ -292,10 +287,6 @@ def link_old_member(data, user):
Since this runs AFTER registration, we need to delete the user on any Since this runs AFTER registration, we need to delete the user on any
failures or else the username will be taken when they try again failures or else the username will be taken when they try again
''' '''
if not old_models:
msg = 'Unable to link, old DB wasn\'t imported.'
logger.info(msg)
raise ValidationError(dict(email=msg))
try: try:
member = models.Member.objects.get(old_email__iexact=data['email']) member = models.Member.objects.get(old_email__iexact=data['email'])
@ -342,12 +333,11 @@ def link_old_member(data, user):
models.Training.objects.filter(member_id=member.id).update(user=user) models.Training.objects.filter(member_id=member.id).update(user=user)
def create_new_member(data, user): def create_new_member(data, user):
if old_models: members = models.Member.objects
old_members = old_models.Members.objects.using('old_portal') if members.filter(old_email__iexact=data['email']).exists():
if old_members.filter(email__iexact=data['email']).exists(): msg = 'Account was found in old portal.'
msg = 'Account was found in old portal.' logger.info(msg)
logger.info(msg) raise ValidationError(dict(email=msg))
raise ValidationError(dict(email=msg))
if utils_ldap.is_configured(): if utils_ldap.is_configured():
result = utils_ldap.find_user(user.username) result = utils_ldap.find_user(user.username)