Handle multiple preregistration user objects when choosing streams

(imported from commit 52faa0256a719bed8a8ccc120f8177cce20450e2)
This commit is contained in:
Leo Franchi 2013-04-09 13:10:40 -04:00
parent 1bd5f788b3
commit fb2b3ae21a
2 changed files with 12 additions and 2 deletions

View File

@ -27,6 +27,8 @@ from zephyr.lib.cache import cache_with_key, user_profile_by_id_cache_key, \
from zephyr.decorator import get_user_profile_by_email, json_to_list, JsonableError from zephyr.decorator import get_user_profile_by_email, json_to_list, JsonableError
from zephyr.lib.event_queue import request_event_queue, get_user_events from zephyr.lib.event_queue import request_event_queue, get_user_events
import confirmation.settings
from zephyr import tornado_callbacks from zephyr import tornado_callbacks
import subprocess import subprocess
@ -731,9 +733,11 @@ def do_finish_tutorial(user_profile):
# We want to add the default subs list iff there were no subs # We want to add the default subs list iff there were no subs
try: try:
prereg_user = PreregistrationUser.objects.get(email=user_profile.email) prereg_user = PreregistrationUser.objects.filter(email=user_profile.email,
status=confirmation.settings.STATUS_ACTIVE) \
.order_by('-id')[0]
streams = prereg_user.streams.all() streams = prereg_user.streams.all()
except PreregistrationUser.DoesNotExist: except IndexError:
# If the user signed up via a mechanism other than # If the user signed up via a mechanism other than
# PreregistrationUser (e.g. Google Apps connect or MitUser), # PreregistrationUser (e.g. Google Apps connect or MitUser),
# just give them the default streams. # just give them the default streams.

View File

@ -225,6 +225,12 @@ def accounts_register(request):
user_profile.email, user_profile.email,
) )
) )
# Mark any other PreregistrationUsers that are STATUS_ACTIVE as inactive
# so we can find the PreregistrationUser that we are actually working
# with here
PreregistrationUser.objects.filter(email=email) \
.exclude(id=prereg_user.id) \
.update(status=0)
notify_new_user(user_profile) notify_new_user(user_profile)
queue_json_publish( queue_json_publish(