Pass environment role choices directly from the view to the template instead of via the form
This commit is contained in:
parent
54af62a58a
commit
83c4483c42
@ -1,17 +1,15 @@
|
||||
from flask_wtf import FlaskForm
|
||||
from wtforms.validators import Optional, Required
|
||||
from wtforms.validators import Required
|
||||
|
||||
from atst.forms.fields import SelectField
|
||||
|
||||
from .data import WORKSPACE_ROLES, ENVIRONMENT_ROLES
|
||||
from .data import WORKSPACE_ROLES
|
||||
|
||||
|
||||
class EditMemberForm(FlaskForm):
|
||||
# This form also accepts a field for each environment in each project
|
||||
# that the user is a member of
|
||||
|
||||
workspace_role = SelectField(
|
||||
"Workspace Role", choices=WORKSPACE_ROLES, validators=[Required()]
|
||||
)
|
||||
|
||||
environment_role = SelectField(
|
||||
"Environment Role", choices=ENVIRONMENT_ROLES, validators=[Optional()]
|
||||
)
|
||||
|
@ -21,6 +21,7 @@ from atst.forms.new_project import NewProjectForm
|
||||
from atst.forms.new_member import NewMemberForm
|
||||
from atst.forms.edit_member import EditMemberForm
|
||||
from atst.forms.workspace import WorkspaceForm
|
||||
from atst.forms.data import ENVIRONMENT_ROLES
|
||||
from atst.domain.authz import Authorization
|
||||
from atst.models.permissions import Permissions
|
||||
|
||||
@ -224,6 +225,7 @@ def view_member(workspace_id, member_id):
|
||||
member=member,
|
||||
projects=projects,
|
||||
form=form,
|
||||
choices=ENVIRONMENT_ROLES,
|
||||
EnvironmentRoles=EnvironmentRoles,
|
||||
)
|
||||
|
||||
|
@ -67,7 +67,7 @@
|
||||
{% set role = EnvironmentRoles.get(member.user_id, env.id).role %}
|
||||
|
||||
<li class='block-list__item'>
|
||||
<edit-workspace-member inline-template initial-data='{{ role }}' v-bind:choices='{{ form.environment_role.choices | tojson }}'>
|
||||
<edit-workspace-member inline-template initial-data='{{ role }}' v-bind:choices='{{ choices | tojson }}'>
|
||||
<div class='project-list-item__environment'>
|
||||
<span class='project-list-item__environment__link'>
|
||||
{{ env.name }}
|
||||
@ -81,7 +81,7 @@
|
||||
{% call Modal(name=env.name + 'RolesModal', dismissable=False) %}
|
||||
<div class='block-list'>
|
||||
<ul>
|
||||
{% for choice in form.environment_role.choices %}
|
||||
{% for choice in choices %}
|
||||
<li class='block-list__item block-list__item--selectable'>
|
||||
|
||||
{% if choice[0] != "" %}
|
||||
|
Loading…
x
Reference in New Issue
Block a user