Create environments while creating project

This commit is contained in:
richard-dds
2018-08-22 17:00:05 -04:00
parent fc07ef5230
commit 8ac271e83e
3 changed files with 18 additions and 4 deletions

View File

@@ -10,3 +10,9 @@ class Environments(object):
db.session.commit()
return environment
@classmethod
def create_many(cls, project, names):
for name in names:
environment = Environment(project=project, name=name)
db.session.add(environment)
db.session.commit()

View File

@@ -1,11 +1,13 @@
from atst.database import db
from atst.models.project import Project
from atst.domain.environments import Environments
class Projects(object):
@classmethod
def create(cls, workspace, name, description):
def create(cls, workspace, name, description, environment_names):
project = Project(workspace=workspace, name=name, description=description)
Environments.create_many(project, environment_names)
db.session.add(project)
db.session.commit()