move data property into the base EnvironmentForm so that NO_ACCESS is converted to None when creating a new application member
This commit is contained in:
parent
afd84e178f
commit
c37c5d72b9
@ -19,6 +19,13 @@ class EnvironmentForm(FlaskForm):
|
||||
filters=[lambda x: None if x == "None" else x],
|
||||
)
|
||||
|
||||
@property
|
||||
def data(self):
|
||||
_data = super().data
|
||||
if "role" in _data and _data["role"] == NO_ACCESS:
|
||||
_data["role"] = None
|
||||
return _data
|
||||
|
||||
|
||||
class PermissionsForm(FlaskForm):
|
||||
perms_env_mgmt = BooleanField(
|
||||
|
@ -113,7 +113,7 @@ TEAM_EXPERIENCE = [
|
||||
|
||||
ENV_ROLE_NO_ACCESS = "No Access"
|
||||
ENV_ROLES = [(role.value, role.value) for role in CSPRole] + [
|
||||
(ENV_ROLE_NO_ACCESS, "No access")
|
||||
(ENV_ROLE_NO_ACCESS, ENV_ROLE_NO_ACCESS)
|
||||
]
|
||||
|
||||
JEDI_CLIN_TYPES = [
|
||||
|
@ -3,7 +3,7 @@ from wtforms.fields import FormField, FieldList, HiddenField, RadioField, String
|
||||
from wtforms.validators import Required
|
||||
|
||||
from .application_member import EnvironmentForm as BaseEnvironmentForm
|
||||
from .data import ENV_ROLES, ENV_ROLE_NO_ACCESS as NO_ACCESS
|
||||
from .data import ENV_ROLES
|
||||
from .forms import BaseForm
|
||||
from atst.forms.fields import SelectField
|
||||
from atst.domain.permission_sets import PermissionSets
|
||||
@ -18,13 +18,6 @@ class EnvironmentForm(BaseEnvironmentForm):
|
||||
filters=[lambda x: None if x == "None" else x],
|
||||
)
|
||||
|
||||
@property
|
||||
def data(self):
|
||||
_data = super().data
|
||||
if "role" in _data and _data["role"] == NO_ACCESS:
|
||||
_data["role"] = None
|
||||
return _data
|
||||
|
||||
|
||||
class PermissionsForm(FlaskForm):
|
||||
perms_team_mgmt = SelectField(
|
||||
|
@ -22,7 +22,7 @@ def test_environment_form_default_no_access():
|
||||
assert form.data == {
|
||||
"environment_id": 123,
|
||||
"environment_name": "testing",
|
||||
"role": NO_ACCESS,
|
||||
"role": None,
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user