Fix populate_db pointer restore.

(imported from commit e7984f5a762fde833c3b8520ef556fbd841aacbb)
This commit is contained in:
Tim Abbott 2012-12-11 16:48:36 -05:00
parent b14e4d2a57
commit 565acffbc5

View File

@ -610,9 +610,10 @@ def restore_saved_messages():
# Set restored pointers to the very latest messages
with transaction.commit_on_success():
for up in UserProfile.objects.all():
for user_profile in UserProfile.objects.all():
try:
top = UserMessage.objects.filter(user_profile_id=up.id).order_by("-message")[0]
top = UserMessage.objects.filter(
user_profile_id=user_profile.id).order_by("-message")[0]
user_profile.pointer = top.message_id
except IndexError:
user_profile.pointer = -1