diff --git a/zephyr/management/commands/populate_db.py b/zephyr/management/commands/populate_db.py index f0f9b91949..a9855368bc 100644 --- a/zephyr/management/commands/populate_db.py +++ b/zephyr/management/commands/populate_db.py @@ -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 diff --git a/zephyr/models.py b/zephyr/models.py index e876e00686..d0c62b89c8 100644 --- a/zephyr/models.py +++ b/zephyr/models.py @@ -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):