Hook up to button
This commit is contained in:
parent
35150dfa10
commit
ae70a551a9
@ -33,6 +33,20 @@ class WorkspaceRoles(object):
|
|||||||
|
|
||||||
return workspace_role
|
return workspace_role
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_by_id(cls, id_):
|
||||||
|
try:
|
||||||
|
workspace_role = (
|
||||||
|
db.session.query(WorkspaceRole)
|
||||||
|
.join(User)
|
||||||
|
.filter(WorkspaceRole.id == id_)
|
||||||
|
.one()
|
||||||
|
)
|
||||||
|
except NoResultFound:
|
||||||
|
workspace_role = None
|
||||||
|
|
||||||
|
return workspace_role
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _get_active_workspace_role(cls, workspace_id, user_id):
|
def _get_active_workspace_role(cls, workspace_id, user_id):
|
||||||
try:
|
try:
|
||||||
|
@ -3,6 +3,7 @@ from atst.domain.authz import Authorization
|
|||||||
from atst.models.permissions import Permissions
|
from atst.models.permissions import Permissions
|
||||||
from atst.domain.users import Users
|
from atst.domain.users import Users
|
||||||
from atst.domain.workspace_roles import WorkspaceRoles
|
from atst.domain.workspace_roles import WorkspaceRoles
|
||||||
|
from atst.domain.environments import Environments
|
||||||
from atst.models.workspace_role import Status as WorkspaceRoleStatus
|
from atst.models.workspace_role import Status as WorkspaceRoleStatus
|
||||||
|
|
||||||
from .query import WorkspacesQuery
|
from .query import WorkspacesQuery
|
||||||
@ -140,13 +141,15 @@ class Workspaces(object):
|
|||||||
WorkspacesQuery.add_and_commit(workspace)
|
WorkspacesQuery.add_and_commit(workspace)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def revoke_access(cls, user, workspace, target_workspace_role):
|
def revoke_access(cls, user, workspace_id, workspace_role_id):
|
||||||
# TODO: What permission to here? Do we need a new one?
|
# TODO: What permission to here? Do we need a new one?
|
||||||
# Authorization.check_workspace_permission(
|
# Authorization.check_workspace_permission(
|
||||||
# user, workspace, Permissions.REQUEST_NEW_CSP_ROLE, "revoke workspace access"
|
# user, workspace, Permissions.REQUEST_NEW_CSP_ROLE, "revoke workspace access"
|
||||||
# )
|
# )
|
||||||
target_workspace_role.status = WorkspaceRoleStatus.DISABLED
|
workspace = WorkspacesQuery.get(workspace_id)
|
||||||
|
workspace_role = WorkspaceRoles.get_by_id(workspace_role_id)
|
||||||
|
workspace_role.status = WorkspaceRoleStatus.DISABLED
|
||||||
for environment in workspace.all_environments:
|
for environment in workspace.all_environments:
|
||||||
# TODO: Implement Environments.revoke_access
|
# TODO: Implement Environments.revoke_access
|
||||||
Environments.revoke_access(user, environment, target_workspace_role.user)
|
Environments.revoke_access(user, environment, workspace_role.user)
|
||||||
return WorkspacesQuery.add_and_commit(target_workspace_role)
|
return WorkspacesQuery.add_and_commit(workspace_role)
|
||||||
|
@ -53,6 +53,12 @@
|
|||||||
confirm_msg="Are you sure? This will send an email to invite the user to join this workspace."
|
confirm_msg="Are you sure? This will send an email to invite the user to join this workspace."
|
||||||
)}}
|
)}}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{{ ConfirmationButton (
|
||||||
|
"Remove Workspace Access",
|
||||||
|
url_for("workspaces.revoke_access", workspace_id=workspace.id, member_id=member.id),
|
||||||
|
form.csrf_token,
|
||||||
|
confirm_msg="Are you sure? This will remove this user from the workspace.",
|
||||||
|
)}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -307,5 +307,5 @@ def test_can_create_workspaces_with_matching_names():
|
|||||||
def test_can_remove_workspace_access():
|
def test_can_remove_workspace_access():
|
||||||
workspace = WorkspaceFactory.create()
|
workspace = WorkspaceFactory.create()
|
||||||
workspace_role = WorkspaceRoleFactory.create(workspace=workspace)
|
workspace_role = WorkspaceRoleFactory.create(workspace=workspace)
|
||||||
Workspaces.revoke_access(workspace.owner, workspace, workspace_role)
|
Workspaces.revoke_access(workspace.owner, workspace.id, workspace_role.id)
|
||||||
assert Workspaces.for_user(workspace_role.user) == []
|
assert Workspaces.for_user(workspace_role.user) == []
|
||||||
|
Loading…
x
Reference in New Issue
Block a user