Rename WorkspaceQuery to WorkspacesQuery
This commit is contained in:
parent
cf653e9ad2
commit
9c24206ae3
@ -7,7 +7,7 @@ from atst.models.workspace import Workspace
|
|||||||
from atst.models.workspace_role import WorkspaceRole
|
from atst.models.workspace_role import WorkspaceRole
|
||||||
|
|
||||||
|
|
||||||
class WorkspaceQuery(Query):
|
class WorkspacesQuery(Query):
|
||||||
model = Workspace
|
model = Workspace
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@ -4,7 +4,7 @@ from atst.models.permissions import Permissions
|
|||||||
from atst.domain.users import Users
|
from atst.domain.users import Users
|
||||||
from atst.domain.workspace_users import WorkspaceUsers
|
from atst.domain.workspace_users import WorkspaceUsers
|
||||||
|
|
||||||
from .query import WorkspaceQuery
|
from .query import WorkspacesQuery
|
||||||
from .scopes import ScopedWorkspace
|
from .scopes import ScopedWorkspace
|
||||||
|
|
||||||
|
|
||||||
@ -12,14 +12,14 @@ class Workspaces(object):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def create(cls, request, name=None):
|
def create(cls, request, name=None):
|
||||||
name = name or request.id
|
name = name or request.id
|
||||||
workspace = WorkspaceQuery.create(request=request, name=name)
|
workspace = WorkspacesQuery.create(request=request, name=name)
|
||||||
Workspaces._create_workspace_role(request.creator, workspace, "owner")
|
Workspaces._create_workspace_role(request.creator, workspace, "owner")
|
||||||
WorkspaceQuery.add_and_commit(workspace)
|
WorkspacesQuery.add_and_commit(workspace)
|
||||||
return workspace
|
return workspace
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get(cls, user, workspace_id):
|
def get(cls, user, workspace_id):
|
||||||
workspace = WorkspaceQuery.get(workspace_id)
|
workspace = WorkspacesQuery.get(workspace_id)
|
||||||
Authorization.check_workspace_permission(
|
Authorization.check_workspace_permission(
|
||||||
user, workspace, Permissions.VIEW_WORKSPACE, "get workspace"
|
user, workspace, Permissions.VIEW_WORKSPACE, "get workspace"
|
||||||
)
|
)
|
||||||
@ -28,7 +28,7 @@ class Workspaces(object):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_for_update(cls, user, workspace_id):
|
def get_for_update(cls, user, workspace_id):
|
||||||
workspace = WorkspaceQuery.get(workspace_id)
|
workspace = WorkspacesQuery.get(workspace_id)
|
||||||
Authorization.check_workspace_permission(
|
Authorization.check_workspace_permission(
|
||||||
user, workspace, Permissions.ADD_APPLICATION_IN_WORKSPACE, "add project"
|
user, workspace, Permissions.ADD_APPLICATION_IN_WORKSPACE, "add project"
|
||||||
)
|
)
|
||||||
@ -37,11 +37,11 @@ class Workspaces(object):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_by_request(cls, request):
|
def get_by_request(cls, request):
|
||||||
return WorkspaceQuery.get_by_request(request)
|
return WorkspacesQuery.get_by_request(request)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_with_members(cls, user, workspace_id):
|
def get_with_members(cls, user, workspace_id):
|
||||||
workspace = WorkspaceQuery.get(workspace_id)
|
workspace = WorkspacesQuery.get(workspace_id)
|
||||||
Authorization.check_workspace_permission(
|
Authorization.check_workspace_permission(
|
||||||
user,
|
user,
|
||||||
workspace,
|
workspace,
|
||||||
@ -54,9 +54,9 @@ class Workspaces(object):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def for_user(cls, user):
|
def for_user(cls, user):
|
||||||
if Authorization.has_atat_permission(user, Permissions.VIEW_WORKSPACE):
|
if Authorization.has_atat_permission(user, Permissions.VIEW_WORKSPACE):
|
||||||
workspaces = WorkspaceQuery.get_all()
|
workspaces = WorkspacesQuery.get_all()
|
||||||
else:
|
else:
|
||||||
workspaces = WorkspaceQuery.get_for_user(user)
|
workspaces = WorkspacesQuery.get_for_user(user)
|
||||||
return workspaces
|
return workspaces
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@ -95,6 +95,6 @@ class Workspaces(object):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def _create_workspace_role(cls, user, workspace, role_name):
|
def _create_workspace_role(cls, user, workspace, role_name):
|
||||||
role = Roles.get(role_name)
|
role = Roles.get(role_name)
|
||||||
workspace_role = WorkspaceQuery.create_workspace_role(user, role, workspace)
|
workspace_role = WorkspacesQuery.create_workspace_role(user, role, workspace)
|
||||||
WorkspaceQuery.add_and_commit(workspace_role)
|
WorkspacesQuery.add_and_commit(workspace_role)
|
||||||
return workspace_role
|
return workspace_role
|
||||||
|
Loading…
x
Reference in New Issue
Block a user