basic workspace model and repository implementation
This commit is contained in:
@@ -1,23 +1,44 @@
|
||||
from sqlalchemy.orm.exc import NoResultFound
|
||||
|
||||
from atst.database import db
|
||||
from atst.domain.exceptions import NotFoundError
|
||||
from atst.models.workspace import Workspace
|
||||
|
||||
|
||||
class Workspaces(object):
|
||||
MOCK_WORKSPACES = [
|
||||
{
|
||||
"name": "Unclassified IaaS and PaaS for Defense Digital Service (DDS)",
|
||||
"id": "5966187a-eff9-44c3-aa15-4de7a65ac7ff",
|
||||
"task_order": {"number": 123456},
|
||||
"user_count": 23,
|
||||
}
|
||||
]
|
||||
# will a request have a TO association?
|
||||
# do we automatically create an entry for the request.creator in the
|
||||
# workspace_roles table?
|
||||
|
||||
@classmethod
|
||||
def create(cls, request, task_order, name=None):
|
||||
name = name or request.id
|
||||
return Workspace(request=request, task_order=task_order, name=name)
|
||||
|
||||
@classmethod
|
||||
def get(cls, workspace_id):
|
||||
return cls.MOCK_WORKSPACES[0]
|
||||
try:
|
||||
workspace = db.session.query(Workspace).filter_by(id=workspace_id).one()
|
||||
except NoResultFound:
|
||||
raise NotFoundError("workspace")
|
||||
|
||||
return workspace
|
||||
|
||||
@classmethod
|
||||
def get_many(cls):
|
||||
return cls.MOCK_WORKSPACES
|
||||
def get_by_request(cls, request):
|
||||
try:
|
||||
workspace = db.session.query(Workspace).filter_by(request=request).one()
|
||||
except NoResultFound:
|
||||
raise NotFoundError("workspace")
|
||||
|
||||
return workspace
|
||||
|
||||
|
||||
class Projects(object):
|
||||
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
@classmethod
|
||||
def create(cls, creator_id, body):
|
||||
pass
|
||||
@@ -67,6 +88,9 @@ class Projects(object):
|
||||
|
||||
class Members(object):
|
||||
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
@classmethod
|
||||
def create(cls, creator_id, body):
|
||||
pass
|
||||
|
Reference in New Issue
Block a user