Update function to determine when invite can be resent and added lots of
tests
This commit is contained in:
@@ -77,7 +77,10 @@ class Invitation(Base, TimestampsMixin, AuditableMixin):
|
||||
|
||||
@property
|
||||
def is_expired(self):
|
||||
return datetime.datetime.now(self.expiration_time.tzinfo) > self.expiration_time
|
||||
return (
|
||||
datetime.datetime.now(self.expiration_time.tzinfo) > self.expiration_time
|
||||
and not self.status == Status.ACCEPTED
|
||||
)
|
||||
|
||||
@property
|
||||
def workspace(self):
|
||||
|
@@ -117,6 +117,10 @@ class WorkspaceRole(Base, mixins.TimestampsMixin, mixins.AuditableMixin):
|
||||
def role_displayname(self):
|
||||
return self.role.display_name
|
||||
|
||||
@property
|
||||
def is_active(self):
|
||||
return self.status == Status.ACTIVE
|
||||
|
||||
@property
|
||||
def num_environment_roles(self):
|
||||
return (
|
||||
@@ -147,8 +151,13 @@ class WorkspaceRole(Base, mixins.TimestampsMixin, mixins.AuditableMixin):
|
||||
|
||||
@property
|
||||
def can_resend_invitation(self):
|
||||
return self.latest_invitation and (
|
||||
self.latest_invitation.is_rejected or self.latest_invitation.is_expired
|
||||
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
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user