Populate form w/ data

This commit is contained in:
leigh-mil
2019-09-12 16:23:56 -04:00
parent ab102470bf
commit 89cb5a160c
3 changed files with 18 additions and 66 deletions

View File

@@ -34,6 +34,7 @@ class PermissionsForm(FlaskForm):
description=translate(
"portfolios.applications.members.form.env_mgmt.description"
),
false_values=(False, "False", 'false', ''),
)
perms_team_mgmt = BooleanField(
translate("portfolios.applications.members.form.team_mgmt.label"),
@@ -41,6 +42,7 @@ class PermissionsForm(FlaskForm):
description=translate(
"portfolios.applications.members.form.team_mgmt.description"
),
false_values=(False, "False", 'false', ''),
)
perms_del_env = BooleanField(
translate("portfolios.applications.members.form.del_env.label"),
@@ -73,40 +75,6 @@ class NewForm(BaseForm):
environment_roles = FieldList(FormField(EnvironmentForm))
class UpdatePermissionsForm(FlaskForm):
perms_team_mgmt = SelectField(
translate("portfolios.applications.members.new.manage_team"),
choices=[
(PermissionSets.VIEW_APPLICATION, "View"),
(PermissionSets.EDIT_APPLICATION_TEAM, "Edit"),
],
)
perms_env_mgmt = SelectField(
translate("portfolios.applications.members.new.manage_envs"),
choices=[
(PermissionSets.VIEW_APPLICATION, "View"),
(PermissionSets.EDIT_APPLICATION_ENVIRONMENTS, "Edit"),
],
)
perms_del_env = SelectField(
choices=[
(PermissionSets.VIEW_APPLICATION, "No"),
(PermissionSets.DELETE_APPLICATION_ENVIRONMENTS, "Yes"),
]
)
@property
def data(self):
_data = super().data
_data.pop("csrf_token", None)
permission_sets = []
for field in _data:
if _data[field] is not None:
permission_sets.append(_data[field])
return permission_sets
class UpdateMemberForm(BaseForm):
permission_sets = FormField(PermissionsForm)
environment_roles = FieldList(FormField(EnvironmentForm))