invite: Fix invitations removed from list too soon.

On invitations panel, invites were being removed when
the user clicked on invitation's link. Now we only remove
it when the user completes registration.

Fixes: #12281
This commit is contained in:
arunikaydav42
2020-02-15 11:36:48 +05:30
committed by Tim Abbott
parent de00c3cd6a
commit 4680d504de
5 changed files with 43 additions and 10 deletions

View File

@@ -43,7 +43,8 @@ def generate_key() -> str:
ConfirmationObjT = Union[MultiuseInvite, PreregistrationUser, EmailChangeStatus]
def get_object_from_key(confirmation_key: str,
confirmation_type: int) -> ConfirmationObjT:
confirmation_type: int,
activate_object: bool=True) -> ConfirmationObjT:
# Confirmation keys used to be 40 characters
if len(confirmation_key) not in (24, 40):
raise ConfirmationKeyException(ConfirmationKeyException.WRONG_LENGTH)
@@ -58,7 +59,7 @@ def get_object_from_key(confirmation_key: str,
raise ConfirmationKeyException(ConfirmationKeyException.EXPIRED)
obj = confirmation.content_object
if hasattr(obj, "status"):
if activate_object and hasattr(obj, "status"):
obj.status = getattr(settings, 'STATUS_ACTIVE', 1)
obj.save(update_fields=['status'])
return obj