confirmation: Rename STATUS_ACTIVE to STATUS_USED.

That's much more descriptive of what that value actually means about the
Confirmation objects.
This commit is contained in:
Mateusz Mandera
2022-07-16 20:09:13 +02:00
committed by Tim Abbott
parent 0ffdc96301
commit fa7700df11
7 changed files with 14 additions and 14 deletions

View File

@@ -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"

View File

@@ -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

View File

@@ -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

View File

@@ -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:

View File

@@ -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)

View File

@@ -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)

View File

@@ -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)