Workspace member buttons #162641480
This commit is contained in:
leigh-mil
2018-12-20 09:48:21 -05:00
committed by GitHub
5 changed files with 138 additions and 27 deletions

View File

@@ -146,7 +146,10 @@ class Workspaces(object):
@classmethod
def can_revoke_access_for(cls, workspace, workspace_role):
return workspace_role.user != workspace.owner
return (
workspace_role.user != workspace.owner
and workspace_role.status == WorkspaceRoleStatus.ACTIVE
)
@classmethod
def revoke_access(cls, user, workspace_id, workspace_role_id):

View File

@@ -77,7 +77,18 @@ 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 is_inactive(self):
return self.is_expired or self.status in [
Status.REJECTED_WRONG_USER,
Status.REJECTED_EXPIRED,
Status.REVOKED,
]
@property
def workspace(self):

View File

@@ -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,8 @@ 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_inactive
)