actions: Change prereg_user.status in revoke_preregistration_users.

It's clearer to have all the logic adjusting PreregistrationUser
statuses in one place rather than scattered.
This commit is contained in:
Mateusz Mandera
2021-02-13 19:59:27 +01:00
committed by Tim Abbott
parent c651bed0d4
commit 22ac0f152e

View File

@@ -463,8 +463,6 @@ def process_new_human_user(
mit_beta_user = realm.is_zephyr_mirror_realm
if prereg_user is not None:
prereg_user.status = confirmation_settings.STATUS_ACTIVE
prereg_user.save(update_fields=["status"])
streams = prereg_user.streams.all()
acting_user: Optional[UserProfile] = prereg_user.referred_by
else:
@@ -526,6 +524,10 @@ def revoke_preregistration_users(
if realm_creation and used_preregistration_user is None:
raise AssertionError("realm_creation should only happen with a PreregistrationUser")
if used_preregistration_user is not None:
used_preregistration_user.status = confirmation_settings.STATUS_ACTIVE
used_preregistration_user.save(update_fields=["status"])
# Mark any other PreregistrationUsers in the realm that are STATUS_ACTIVE as
# inactive so we can keep track of the PreregistrationUser we
# actually used for analytics.