Remove option to revoke from expired workspace invitation
This commit is contained in:
leigh-mil 2018-11-28 15:49:36 -05:00 committed by GitHub
commit 2dd26e6cf1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 1 deletions

View File

@ -87,3 +87,7 @@ class Invitation(Base, TimestampsMixin, AuditableMixin):
@property
def user_name(self):
return self.workspace_role.user.full_name
@property
def is_revokable(self):
return self.is_pending and not self.is_expired

View File

@ -40,7 +40,7 @@
<a href='{{ url_for("users.user") }}' class='icon-link'>edit account details</a>
{% endif %}
<div>
{% if member.latest_invitation.is_pending %}
{% if member.latest_invitation.is_revokable %}
{{ ConfirmationButton(
"Revoke Invitation",
url_for("workspaces.revoke_invitation", workspace_id=workspace.id, token=member.latest_invitation.token),

View File

@ -0,0 +1,23 @@
import pytest
import datetime
from atst.models.invitation import Invitation, Status
from tests.factories import InvitationFactory
def test_expired_invite_is_not_revokable():
invite = InvitationFactory.create(
expiration_time=datetime.datetime.now() - datetime.timedelta(minutes=60)
)
assert not invite.is_revokable
def test_unexpired_invite_is_revokable():
invite = InvitationFactory.create()
assert invite.is_revokable
def test_invite_is_not_revokable_if_invite_is_not_pending():
invite = InvitationFactory.create(status=Status.ACCEPTED)
assert not invite.is_revokable