mirror of https://github.com/zulip/zulip.git
dump_pointers and dump_passwords: Add error handling for deleted users.
(imported from commit 556c29133a4734014d4640d875c6d6fccc118668)
This commit is contained in:
parent
197d0dcc01
commit
dc2057ff73
|
@ -11,7 +11,11 @@ def dump():
|
|||
|
||||
def restore(change):
|
||||
for (email, password) in simplejson.loads(file("dumped-passwords").read()):
|
||||
user = User.objects.get(email__iexact=email)
|
||||
try:
|
||||
user = User.objects.get(email__iexact=email)
|
||||
except User.DoesNotExist:
|
||||
print "Skipping...", email
|
||||
continue
|
||||
if change:
|
||||
user.password = password
|
||||
user.save()
|
||||
|
|
|
@ -17,13 +17,20 @@ def dump():
|
|||
|
||||
def restore(change):
|
||||
for (email, timestamp) in simplejson.loads(file("dumped-pointers").read()):
|
||||
u = UserProfile.objects.get(user__email__iexact=email)
|
||||
try:
|
||||
u = UserProfile.objects.get(user__email__iexact=email)
|
||||
except UserProfile.DoesNotExist:
|
||||
print "Skipping...", email
|
||||
continue
|
||||
if timestamp == -1:
|
||||
pointer = -1
|
||||
else:
|
||||
pointer = Message.objects.filter(
|
||||
pub_date__gte=timestamp_to_datetime(timestamp)).order_by("id")[0].id
|
||||
print "%s: pointer %s => %s" % (email, u.pointer, pointer)
|
||||
try:
|
||||
pointer = Message.objects.filter(
|
||||
pub_date__gte=timestamp_to_datetime(timestamp - 1)).order_by("id")[0].id
|
||||
except IndexError:
|
||||
print "Alert...", email, timestamp
|
||||
continue
|
||||
if change:
|
||||
u.pointer = pointer
|
||||
u.save()
|
||||
|
|
Loading…
Reference in New Issue