Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
confirmation: Rename STATUS_ACTIVE to STATUS_USED.
Mateusz Manderafa7700df11dd
diff --git a/analytics/views/support.py b/analytics/views/support.pyindex a29b82ac306..5cbdcede41e 100644--- a/analytics/views/support.py+++ b/analytics/views/support.py@@ -16,7 +16,7 @@ from django.utils.timezone import now as timezone_nowfrom django.utils.translation import gettext as _from confirmation.models import Confirmation, confirmation_url-from confirmation.settings import STATUS_ACTIVE+from confirmation.settings import STATUS_USEDfrom zerver.actions.create_realm import do_change_realm_subdomainfrom zerver.actions.realm_settings import (do_change_realm_org_type,@@ -90,7 +90,7 @@ def get_confirmations(assert content_object is not Noneif hasattr(content_object, "status"):- if content_object.status == STATUS_ACTIVE:+ if content_object.status == STATUS_USED:link_status = "Link has been used"else:link_status = "Link has not been used"diff --git a/confirmation/models.py b/confirmation/models.pyindex 6193e77d2c8..fe93daaf5c7 100644--- a/confirmation/models.py+++ b/confirmation/models.py@@ -68,7 +68,7 @@ def get_object_from_key(obj = confirmation.content_objectassert obj is not Noneif activate_object and hasattr(obj, "status"):- obj.status = getattr(settings, "STATUS_ACTIVE", 1)+ obj.status = getattr(settings, "STATUS_USED", 1)obj.save(update_fields=["status"])return objdiff --git a/confirmation/settings.py b/confirmation/settings.pyindex c426220ba13..4a53e03149c 100644--- a/confirmation/settings.py+++ b/confirmation/settings.py@@ -2,5 +2,5 @@__revision__ = "$Id: settings.py 12 2008-11-23 19:38:52Z jarek.zgoda $"-STATUS_ACTIVE = 1+STATUS_USED = 1STATUS_REVOKED = 2diff --git a/zerver/actions/create_user.py b/zerver/actions/create_user.pyindex 57a8ce891f0..ff1985e07e2 100644--- a/zerver/actions/create_user.py+++ b/zerver/actions/create_user.py@@ -243,7 +243,7 @@ def process_new_human_user(# we want to tie the newly created user to the PreregistrationUser# it was created from.if prereg_user is not None:- prereg_user.status = confirmation_settings.STATUS_ACTIVE+ prereg_user.status = confirmation_settings.STATUS_USEDprereg_user.created_user = user_profileprereg_user.save(update_fields=["status", "created_user"])@@ -251,7 +251,7 @@ def process_new_human_user(# 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_ACTIVE as+ # 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:diff --git a/zerver/models.py b/zerver/models.pyindex 690166537f8..7887651386c 100644--- a/zerver/models.py+++ b/zerver/models.py@@ -2230,7 +2230,7 @@ class PreregistrationUser(models.Model):password_required: bool = models.BooleanField(default=True)# status: whether an object has been confirmed.- # if confirmed, set to confirmation.settings.STATUS_ACTIVE+ # if confirmed, set to confirmation.settings.STATUS_USEDstatus: int = models.IntegerField(default=0)# The realm should only ever be None for PreregistrationUser@@ -2268,10 +2268,10 @@ def filter_to_valid_prereg_users(If invite_expires_in_days is specified, we return only those PreregistrationUserobjects that were created at most that many days in the past."""- active_value = confirmation_settings.STATUS_ACTIVE+ used_value = confirmation_settings.STATUS_USEDrevoked_value = confirmation_settings.STATUS_REVOKED- query = query.exclude(status__in=[active_value, revoked_value])+ query = query.exclude(status__in=[used_value, revoked_value])if invite_expires_in_minutes is None:# Since invite_expires_in_minutes is None, we're invitation will never# expire, we do not need to check anything else and can simply return@@ -2306,7 +2306,7 @@ class EmailChangeStatus(models.Model):user_profile: UserProfile = models.ForeignKey(UserProfile, on_delete=CASCADE)# status: whether an object has been confirmed.- # if confirmed, set to confirmation.settings.STATUS_ACTIVE+ # if confirmed, set to confirmation.settings.STATUS_USEDstatus: int = models.IntegerField(default=0)realm: Realm = models.ForeignKey(Realm, on_delete=CASCADE)diff --git a/zerver/tests/test_signup.py b/zerver/tests/test_signup.pyindex 51b94663bce..67fe4d4ff55 100644--- a/zerver/tests/test_signup.py+++ b/zerver/tests/test_signup.py@@ -2229,7 +2229,7 @@ so we didn't send them an invitation. We did send invitations to everyone else!")accepted_invite = PreregistrationUser.objects.filter(- email__iexact="[email protected]", status=confirmation_settings.STATUS_ACTIVE+ email__iexact="[email protected]", status=confirmation_settings.STATUS_USED)revoked_invites = PreregistrationUser.objects.filter(email__iexact="[email protected]", status=confirmation_settings.STATUS_REVOKED@@ -2433,7 +2433,7 @@ class InvitationsTestCase(InviteUserBase):"""A GET call to /json/invites returns all unexpired invitations."""- active_value = getattr(confirmation_settings, "STATUS_ACTIVE", "Wrong")+ active_value = getattr(confirmation_settings, "STATUS_USED", "Wrong")self.assertNotEqual(active_value, "Wrong")self.login("iago")@@ -2883,7 +2883,7 @@ class InvitationsTestCase(InviteUserBase):result = self.submit_reg_form_for_user(email, password, key=registration_key)self.assertEqual(result.status_code, 302)prereg_user = PreregistrationUser.objects.get(email=email, referred_by=inviter, realm=realm)- self.assertEqual(prereg_user.status, confirmation_settings.STATUS_ACTIVE)+ self.assertEqual(prereg_user.status, confirmation_settings.STATUS_USED)user = get_user_by_delivery_email(email, realm)self.assertIsNotNone(user)self.assertEqual(user.delivery_email, email)diff --git a/zerver/views/registration.py b/zerver/views/registration.pyindex ca5f800829a..278d3246b4e 100644--- a/zerver/views/registration.py+++ b/zerver/views/registration.py@@ -141,7 +141,7 @@ def check_prereg_key(request: HttpRequest, confirmation_key: str) -> Preregistraif prereg_user.status in [confirmation_settings.STATUS_REVOKED,- confirmation_settings.STATUS_ACTIVE,+ confirmation_settings.STATUS_USED,]:raise ConfirmationKeyException(ConfirmationKeyException.EXPIRED)