mirror of
https://github.com/zulip/zulip.git
synced 2025-11-10 00:46:03 +00:00
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:
@@ -1,6 +1,7 @@
|
||||
from optparse import make_option
|
||||
from django.core.management.base import BaseCommand
|
||||
from zephyr.models import Realm, UserProfile, Message, UserMessage
|
||||
from zephyr.models import Realm, UserProfile, Message, UserMessage, \
|
||||
get_user_profile_by_email
|
||||
from zephyr.lib.timestamp import datetime_to_timestamp, timestamp_to_datetime
|
||||
import simplejson
|
||||
|
||||
@@ -18,7 +19,7 @@ def dump():
|
||||
def restore(change):
|
||||
for (email, timestamp) in simplejson.loads(file("dumped-pointers").read()):
|
||||
try:
|
||||
u = UserProfile.objects.get(user__email__iexact=email)
|
||||
u = get_user_profile_by_email(email)
|
||||
except UserProfile.DoesNotExist:
|
||||
print "Skipping...", email
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user