diff --git a/atst/models/invitation.py b/atst/models/invitation.py index 6d471734..f1fafebf 100644 --- a/atst/models/invitation.py +++ b/atst/models/invitation.py @@ -82,6 +82,14 @@ class Invitation(Base, TimestampsMixin, AuditableMixin): and not self.status == Status.ACCEPTED ) + @property + def is_inactive(self): + return self.is_expired or self.status in [ + Status.REJECTED_WRONG_USER, + Status.REJECTED_EXPIRED, + Status.REVOKED, + ] + @property def workspace(self): if self.workspace_role: diff --git a/atst/models/workspace_role.py b/atst/models/workspace_role.py index 7a01dce9..580dc07f 100644 --- a/atst/models/workspace_role.py +++ b/atst/models/workspace_role.py @@ -152,12 +152,7 @@ class WorkspaceRole(Base, mixins.TimestampsMixin, mixins.AuditableMixin): @property def can_resend_invitation(self): return not self.is_active and ( - self.latest_invitation - and ( - self.latest_invitation.is_rejected - or self.latest_invitation.is_expired - or self.latest_invitation.is_revoked - ) + self.latest_invitation and self.latest_invitation.is_inactive )