Merge pull request #335 from dod-ccpo/fix-workspace-owner-environments

Fix regression in Projects.create
This commit is contained in:
richard-dds
2018-09-25 16:53:05 -04:00
committed by GitHub
3 changed files with 19 additions and 8 deletions

View File

@@ -21,9 +21,13 @@ class Environments(object):
@classmethod
def create_many(cls, project, names):
environments = []
for name in names:
environment = Environment(project=project, name=name)
db.session.add(environment)
environments.append(environment)
db.session.add_all(environments)
return environments
@classmethod
def add_member(cls, environment, user, role):
@@ -31,8 +35,6 @@ class Environments(object):
user=user, environment=environment, role=role
)
db.session.add(environment_user)
db.session.commit()
return environment
@classmethod

View File

@@ -5,7 +5,6 @@ from atst.domain.exceptions import NotFoundError
from atst.models.permissions import Permissions
from atst.models.project import Project
from atst.models.environment import Environment
from atst.models.environment_role import EnvironmentRole
class Projects(object):
@@ -16,9 +15,6 @@ class Projects(object):
Environments.create_many(project, environment_names)
for environment in project.environments:
Environments.add_member(user, environment, user)
db.session.commit()
return project