Prevent saving environment roles as empty strings

This commit is contained in:
Montana 2018-09-25 08:36:50 -04:00
parent e1767488c7
commit 8fd1d93f2e
4 changed files with 3 additions and 7 deletions

View File

@ -27,7 +27,7 @@ class Environments(object):
db.session.commit()
@classmethod
def add_member(cls, user, environment, member, role=None):
def add_member(cls, environment, member, role):
environment_user = EnvironmentRole(
user=member, environment=environment, role=role
)

View File

@ -14,9 +14,6 @@ class Projects(object):
project = Project(workspace=workspace, name=name, description=description)
Environments.create_many(project, environment_names)
for environment in project.environments:
Environments.add_member(user, environment, user)
db.session.add(project)
db.session.commit()

View File

@ -249,7 +249,8 @@ def update_member(workspace_id, member_id):
if re.match("env_", entry):
env_id = entry[4:]
env_role = form_dict[entry]
ids_and_roles.append({"id": env_id, "role": env_role})
if env_role:
ids_and_roles.append({"id": env_id, "role": env_role})
form = EditMemberForm(http_request.form)

View File

@ -74,8 +74,6 @@
</span>
<div class='project-list-item__environment__actions'>
<div>{{ form.data["environment_role"] }}</div>
<span v-bind:class="label_class" v-html:on=displayName></span>
<button v-on:click="openModal('{{ env.name }}RolesModal')" type="button" class="icon-link">set role</button>
{% call Modal(name=env.name + 'RolesModal', dismissable=False) %}