Use get_user_profile_by_email more consistently.

The previous situation was bad for two reasons:

(1) It had a lot of copies of the code, some of them missing pieces:
  UserProfile.objects.get(user__email__iexact=foo)

This was in particular going to be inconvenient since we are dropping
the __user part of that.

(2) It didn't take advantage of our memcached caching.

(imported from commit 2325795f288a7cf306cdae191f5d3080aac0651a)
This commit is contained in:
Tim Abbott
2013-03-28 15:20:31 -04:00
parent 203e5e17ee
commit 198480ef99
21 changed files with 77 additions and 71 deletions

View File

@@ -115,7 +115,7 @@ def compute_mit_user_fullname(email):
@transaction.commit_on_success
def create_mit_user_if_needed(realm, email):
try:
return UserProfile.objects.get(user__email__iexact=email)
return get_user_profile_by_email(email)
except UserProfile.DoesNotExist:
try:
# Forge a user for this person
@@ -126,7 +126,7 @@ def create_mit_user_if_needed(realm, email):
# Unless we raced with another thread doing the same
# thing, in which case we should get the user they made
transaction.commit()
return UserProfile.objects.get(user__email__iexact=email)
return get_user_profile_by_email(email)
def log_message(message):
if not message.sending_client.name.startswith("test:"):