populate_db: Preserve the user's date_joined on replay.

(imported from commit 91dcb4f41e0e58f165db6a7417e57548914ddab7)
This commit is contained in:
Tim Abbott 2012-12-04 15:09:38 -05:00
parent 8e3bcdaa19
commit 81d560dc1f
2 changed files with 5 additions and 3 deletions

View File

@ -529,7 +529,8 @@ def restore_saved_messages():
elif old_message["type"] == "user_activated" or old_message["type"] == "user_created":
# These are rare, so just handle them the slow way
user = User.objects.get(email=old_message["user"])
do_activate_user(user, log=False)
timestamp=datetime.datetime.utcfromtimestamp(float(old_message['timestamp'])).replace(tzinfo=utc)
do_activate_user(user, log=False, timestamp=timestamp)
# Update the cache of users to show this user as activated
users_by_id[user.userprofile.id] = UserProfile.objects.get(user=user)
users[user.email] = user.userprofile

View File

@ -601,13 +601,14 @@ def log_subscription_property_change(user_email, property, property_dict):
event.update(property_dict)
log_event(event)
def do_activate_user(user, log=True):
def do_activate_user(user, log=True, timestamp=time.time()):
user.is_active = True
user.set_password(initial_password(user.email))
user.date_joined = timestamp
user.save()
if log:
log_event({'type': 'user_activated',
'timestamp': time.time(),
'timestamp': timestamp,
'user': user.email})
def do_change_password(user, password, log=True):