-
Notifications
You must be signed in to change notification settings - Fork 3
MPT-11279 vadalidate the parameters introduced by the customer #470
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MPT-11279 vadalidate the parameters introduced by the customer #470
Conversation
40981fc
to
e27e1e5
Compare
99373bc
to
989b1b9
Compare
adobe_vipm/flows/utils/parameter.py
Outdated
def set_params_visibility(params, hidden): | ||
for param in params: | ||
if hidden: | ||
updated = set_parameter_hidden | ||
else: | ||
updated = set_parameter_visible | ||
nonlocal updated_order | ||
updated_order = updated(updated_order, param) | ||
|
||
if agreement_value == "New": | ||
set_params_visibility(PARAM_NEW_CUSTOMER_PARAMETERS, hidden=False) | ||
set_params_visibility( | ||
TRANSFER_CUSTOMER_PARAMETERS + (Param.MEMBERSHIP_ID,), | ||
hidden=True | ||
) | ||
elif agreement_value == "Migrate": | ||
set_params_visibility( | ||
PARAM_NEW_CUSTOMER_PARAMETERS + TRANSFER_CUSTOMER_PARAMETERS, | ||
hidden=True | ||
) | ||
set_params_visibility([Param.MEMBERSHIP_ID], hidden=False) | ||
elif agreement_value == "Transfer": | ||
set_params_visibility(PARAM_NEW_CUSTOMER_PARAMETERS, hidden=True) | ||
set_params_visibility([Param.MEMBERSHIP_ID], hidden=True) | ||
set_params_visibility(TRANSFER_CUSTOMER_PARAMETERS, hidden=False) | ||
|
||
return updated_order |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel this logic a bit complicated and I'm not a big fan of using nonlocal unless if there is a really good reason for it. I believe we could use a map and then call the set_parameter_hidden and set_parameter_visible. Something like:
param_map = {
"new": {
"visible": PARAM_NEW_CUSTOMER_PARAMETERS,
"hidden": TRANSFER_CUSTOMER_PARAMETERS + (Param.MEMBERSHIP_ID,),
},
"Migrate": {
"visible": [Param.MEMBERSHIP_ID],
"hidden": PARAM_NEW_CUSTOMER_PARAMETERS + TRANSFER_CUSTOMER_PARAMETERS,
},
...
}
update_order = set_parameter_visible(update_order, param_map[agreement_value] # I assume all the values have both visible and hidden params ,otherwise we can use an if conditional before with a get
update_order = set_parameter_hidden(update_order, param_map[agreement_value]
return updated_order
989b1b9
to
6ce6d86
Compare
from adobe_vipm.flows.constants import ( | ||
PARAM_REQUIRED_CUSTOMER_ORDER, | ||
Param, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a bit confused with this change and the one on line 63. Are they a Ruff change?
c8d8f56
to
bd3f7eb
Compare
bd3f7eb
to
a08483d
Compare
|
No description provided.