Add form to template
- do not use None as a dropdown value because it was causing issues - cleans up some comments
This commit is contained in:
parent
416ea1de82
commit
de41afa935
@ -12,27 +12,25 @@ class PermissionsForm(FlaskForm):
|
||||
perms_env_mgmt = SelectField(
|
||||
translate("portfolios.applications.members.new.manage_envs"),
|
||||
choices=[
|
||||
(None, "View only"),
|
||||
("", "View only"),
|
||||
(PermissionSets.EDIT_APPLICATION_ENVIRONMENTS, "Edit access"),
|
||||
],
|
||||
filters=[BaseForm.remove_empty_string],
|
||||
)
|
||||
perms_team_mgmt = SelectField(
|
||||
translate("portfolios.applications.members.new.manage_team"),
|
||||
choices=[
|
||||
(None, "View only"),
|
||||
("", "View only"),
|
||||
(PermissionSets.EDIT_APPLICATION_TEAM, "Edit access"),
|
||||
],
|
||||
filters=[BaseForm.remove_empty_string],
|
||||
)
|
||||
perms_del_env = SelectField(
|
||||
choices=[(None, "No"), (PermissionSets.DELETE_APPLICATION_ENVIRONMENTS, "Yes")],
|
||||
filters=[BaseForm.remove_empty_string],
|
||||
choices=[("", "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:
|
||||
@ -47,6 +45,13 @@ class MemberForm(FlaskForm):
|
||||
environment_roles = FieldList(FormField(EnvironmentForm))
|
||||
permission_sets = FormField(PermissionsForm)
|
||||
|
||||
@property
|
||||
def data(self):
|
||||
_data = super().data
|
||||
_data.pop("csrf_token", None)
|
||||
|
||||
return _data
|
||||
|
||||
|
||||
class TeamForm(BaseForm):
|
||||
members = FieldList(FormField(MemberForm))
|
||||
|
@ -32,6 +32,7 @@ def team(application_id):
|
||||
team_data = []
|
||||
for member in application.members:
|
||||
user_id = member.user.id
|
||||
# TODO: if no members, we get a server error
|
||||
user_name = member.user.full_name
|
||||
environment_users[user_id] = {
|
||||
"permissions": {
|
||||
|
@ -4,6 +4,8 @@
|
||||
{% set environment_roles_form = member_form.environment_roles %}
|
||||
{% set permissions_form = member_form.permission_sets %}
|
||||
|
||||
<form method='POST' id="team" action='{{ url_for("applications.team", application_id=application.id) }}' autocomplete="off" enctype="multipart/form-data">
|
||||
{{ team_form.csrf_token }}
|
||||
<toggler inline-template>
|
||||
<li class="accordion-table__item">
|
||||
<div class="accordion-table__item-content row">
|
||||
@ -38,6 +40,8 @@
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endcall %}
|
||||
{{ member_form.user_id() }}
|
||||
</li>
|
||||
</toggler>
|
||||
</form>
|
||||
{% endfor %}
|
||||
|
@ -73,7 +73,7 @@
|
||||
<div class="panel__footer">
|
||||
<div class="action-group save">
|
||||
{% if user_can(permissions.EDIT_APPLICATION_MEMBER) %}
|
||||
{{ SaveButton(text=('common.save' | translate), element="input", form="member-perms") }}
|
||||
{{ SaveButton(text=('common.save' | translate), element="input", form="team") }}
|
||||
{% endif %}
|
||||
|
||||
{% if user_can(permissions.CREATE_APPLICATION_MEMBER) %}
|
||||
|
Loading…
x
Reference in New Issue
Block a user