Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
registration: Remove redundant code.
Sahil Batra00ffa3e8706e
diff --git a/zerver/actions/create_user.py b/zerver/actions/create_user.pyindex ff8442d479a..25d84348fe7 100644--- a/zerver/actions/create_user.py+++ b/zerver/actions/create_user.py@@ -228,24 +228,20 @@ def process_new_human_user(prereg_user.created_user = user_profileprereg_user.save(update_fields=["status", "created_user"])- # In the special case of realm creation, there can be no additional PreregistrationUser- # for us to want to modify - because other realm_creation PreregistrationUsers should be- # left usable for creating different realms.- if not realm_creation:- # Mark any other PreregistrationUsers in the realm that are STATUS_USED as- # inactive so we can keep track of the PreregistrationUser we- # actually used for analytics.- if prereg_user is not None:- PreregistrationUser.objects.filter(- email__iexact=user_profile.delivery_email, realm=user_profile.realm- ).exclude(id=prereg_user.id).update(status=confirmation_settings.STATUS_REVOKED)- else:- PreregistrationUser.objects.filter(- email__iexact=user_profile.delivery_email, realm=user_profile.realm- ).update(status=confirmation_settings.STATUS_REVOKED)+ # Mark any other PreregistrationUsers in the realm that are STATUS_USED as+ # inactive so we can keep track of the PreregistrationUser we+ # actually used for analytics.+ if prereg_user is not None:+ PreregistrationUser.objects.filter(+ email__iexact=user_profile.delivery_email, realm=user_profile.realm+ ).exclude(id=prereg_user.id).update(status=confirmation_settings.STATUS_REVOKED)+ else:+ PreregistrationUser.objects.filter(+ email__iexact=user_profile.delivery_email, realm=user_profile.realm+ ).update(status=confirmation_settings.STATUS_REVOKED)- if prereg_user is not None and prereg_user.referred_by is not None:- notify_invites_changed(user_profile.realm)+ if prereg_user is not None and prereg_user.referred_by is not None:+ notify_invites_changed(user_profile.realm)notify_new_user(user_profile)# Clear any scheduled invitation emails to prevent themdiff --git a/zerver/views/auth.py b/zerver/views/auth.pyindex 5a8fce7bc09..eda081806b3 100644--- a/zerver/views/auth.py+++ b/zerver/views/auth.py@@ -118,18 +118,13 @@ def get_safe_redirect_to(url: str, redirect_host: str) -> str:def create_preregistration_user(email: str,realm: Optional[Realm],- realm_creation: bool = False,password_required: bool = True,full_name: Optional[str] = None,full_name_validated: bool = False,multiuse_invite: Optional[MultiuseInvite] = None,) -> PreregistrationUser:- assert not (realm_creation and realm is not None)- assert not (realm is None and not realm_creation)-return PreregistrationUser.objects.create(email=email,- realm_creation=realm_creation,password_required=password_required,realm=realm,full_name=full_name,diff --git a/zerver/views/development/registration.py b/zerver/views/development/registration.pyindex 63d568d347d..e4750eab07c 100644--- a/zerver/views/development/registration.py+++ b/zerver/views/development/registration.py@@ -49,9 +49,7 @@ def register_development_user(request: HttpRequest) -> HttpResponse:count = UserProfile.objects.count()name = f"user-{count}"email = f"{name}@zulip.com"- prereg = create_preregistration_user(- email, realm, realm_creation=False, password_required=False- )+ prereg = create_preregistration_user(email, realm, password_required=False)activation_url = create_confirmation_link(prereg, Confirmation.USER_REGISTRATION)key = activation_url.split("/")[-1]# Need to add test data to POST request as it doesn't originally contain the required parameters