Move Projects and Environments into their own files
This commit is contained in:
parent
1b7b024bd7
commit
50e2666c3c
12
atst/domain/environments.py
Normal file
12
atst/domain/environments.py
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
from atst.database import db
|
||||||
|
from atst.models.environment import Environment
|
||||||
|
|
||||||
|
|
||||||
|
class Environments(object):
|
||||||
|
@classmethod
|
||||||
|
def create(cls, project, name):
|
||||||
|
environment = Environment(project=project, name=name)
|
||||||
|
db.session.add(environment)
|
||||||
|
db.session.commit()
|
||||||
|
return environment
|
||||||
|
|
13
atst/domain/projects.py
Normal file
13
atst/domain/projects.py
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
from atst.database import db
|
||||||
|
from atst.models.project import Project
|
||||||
|
|
||||||
|
|
||||||
|
class Projects(object):
|
||||||
|
@classmethod
|
||||||
|
def create(cls, workspace, name, description):
|
||||||
|
project = Project(workspace=workspace, name=name, description=description)
|
||||||
|
|
||||||
|
db.session.add(project)
|
||||||
|
db.session.commit()
|
||||||
|
|
||||||
|
return project
|
@ -3,8 +3,6 @@ from sqlalchemy.orm.exc import NoResultFound
|
|||||||
from atst.database import db
|
from atst.database import db
|
||||||
from atst.models.workspace import Workspace
|
from atst.models.workspace import Workspace
|
||||||
from atst.models.workspace_role import WorkspaceRole
|
from atst.models.workspace_role import WorkspaceRole
|
||||||
from atst.models.project import Project
|
|
||||||
from atst.models.environment import Environment
|
|
||||||
from atst.domain.exceptions import NotFoundError, UnauthorizedError
|
from atst.domain.exceptions import NotFoundError, UnauthorizedError
|
||||||
from atst.domain.roles import Roles
|
from atst.domain.roles import Roles
|
||||||
from atst.domain.authz import Authorization
|
from atst.domain.authz import Authorization
|
||||||
@ -68,25 +66,7 @@ class Workspaces(object):
|
|||||||
)
|
)
|
||||||
return workspaces
|
return workspaces
|
||||||
|
|
||||||
|
|
||||||
class Projects(object):
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def create(cls, workspace, name, description):
|
|
||||||
project = Project(workspace=workspace, name=name, description=description)
|
|
||||||
|
|
||||||
db.session.add(project)
|
|
||||||
db.session.commit()
|
|
||||||
|
|
||||||
return project
|
|
||||||
|
|
||||||
|
|
||||||
class Environments(object):
|
|
||||||
@classmethod
|
|
||||||
def create(cls, project, name):
|
|
||||||
environment = Environment(project=project, name=name)
|
|
||||||
db.session.add(environment)
|
|
||||||
db.session.commit()
|
|
||||||
return environment
|
|
||||||
|
|
||||||
|
|
||||||
class Members(object):
|
class Members(object):
|
||||||
|
@ -7,7 +7,9 @@ from flask import (
|
|||||||
url_for,
|
url_for,
|
||||||
)
|
)
|
||||||
|
|
||||||
from atst.domain.workspaces import Workspaces, Members, Projects, Environments
|
from atst.domain.workspaces import Workspaces, Members
|
||||||
|
from atst.domain.projects import Projects
|
||||||
|
from atst.domain.environments import Environments
|
||||||
from atst.forms.new_project import NewProjectForm
|
from atst.forms.new_project import NewProjectForm
|
||||||
|
|
||||||
bp = Blueprint("workspaces", __name__)
|
bp = Blueprint("workspaces", __name__)
|
||||||
|
@ -8,7 +8,8 @@ sys.path.append(parent_dir)
|
|||||||
from atst.app import make_config, make_app
|
from atst.app import make_config, make_app
|
||||||
from atst.domain.users import Users
|
from atst.domain.users import Users
|
||||||
from atst.domain.requests import Requests
|
from atst.domain.requests import Requests
|
||||||
from atst.domain.workspaces import Workspaces, Projects
|
from atst.domain.workspaces import Workspaces
|
||||||
|
from atst.domain.projects import Projects
|
||||||
from atst.domain.exceptions import AlreadyExistsError
|
from atst.domain.exceptions import AlreadyExistsError
|
||||||
from tests.factories import RequestFactory
|
from tests.factories import RequestFactory
|
||||||
from atst.routes.dev import _DEV_USERS as DEV_USERS
|
from atst.routes.dev import _DEV_USERS as DEV_USERS
|
||||||
|
Loading…
x
Reference in New Issue
Block a user