diff --git a/analytics/views/support.py b/analytics/views/support.py index a29b82ac30..5cbdcede41 100644 --- a/analytics/views/support.py +++ b/analytics/views/support.py @@ -16,7 +16,7 @@ from django.utils.timezone import now as timezone_now from django.utils.translation import gettext as _ from confirmation.models import Confirmation, confirmation_url -from confirmation.settings import STATUS_ACTIVE +from confirmation.settings import STATUS_USED from zerver.actions.create_realm import do_change_realm_subdomain from zerver.actions.realm_settings import ( do_change_realm_org_type, @@ -90,7 +90,7 @@ def get_confirmations( assert content_object is not None if 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.py index 6193e77d2c..fe93daaf5c 100644 --- a/confirmation/models.py +++ b/confirmation/models.py @@ -68,7 +68,7 @@ def get_object_from_key( obj = confirmation.content_object assert obj is not None if 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 obj diff --git a/confirmation/settings.py b/confirmation/settings.py index c426220ba1..4a53e03149 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 = 1 STATUS_REVOKED = 2 diff --git a/zerver/actions/create_user.py b/zerver/actions/create_user.py index 57a8ce891f..ff1985e07e 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_USED prereg_user.created_user = user_profile prereg_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.py index 690166537f..7887651386 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_USED status: 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 PreregistrationUser objects that were created at most that many days in the past. """ - active_value = confirmation_settings.STATUS_ACTIVE + used_value = confirmation_settings.STATUS_USED revoked_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_USED status: 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.py index 51b94663bc..67fe4d4ff5 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="foo@zulip.com", status=confirmation_settings.STATUS_ACTIVE + email__iexact="foo@zulip.com", status=confirmation_settings.STATUS_USED ) revoked_invites = PreregistrationUser.objects.filter( email__iexact="foo@zulip.com", 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.py index ca5f800829..278d3246b4 100644 --- a/zerver/views/registration.py +++ b/zerver/views/registration.py @@ -141,7 +141,7 @@ def check_prereg_key(request: HttpRequest, confirmation_key: str) -> Preregistra if prereg_user.status in [ confirmation_settings.STATUS_REVOKED, - confirmation_settings.STATUS_ACTIVE, + confirmation_settings.STATUS_USED, ]: raise ConfirmationKeyException(ConfirmationKeyException.EXPIRED)