Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
def get_options_list(field, control_value=None, control_values=[], **kwargs):
"""
A plug-in for building a list of options for 'Plants'
based on the values selected for the controlling field 'Plant Type'
field: This is the dependent field.
control_value: You won't need to use in this case, but is still required in the kwargs in the function definition.
control_values: A list of values selected on the form for the controlling field.
"""
options = []

if 'Trees' in control_values:
options.extend([
('red_maple', 'Red Maple'),
('coastal_redwood', 'Coastal Redwood'),
('douglas_fir', 'Douglas Fir'),
])

if 'Shrubs' in control_values:
options.extend([
('red_twig_dogwood', 'Red Twig Dogwood'),
('wild_lilac', 'Wild Lilac'),
('summersweet', 'Summersweet'),
])

return options
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
def get_options_list(field, control_value=None, control_value_dict=None, **kwargs):
if not control_value_dict:
return [
("", f"------ Please select a Monitoring Tool and Policy ------")
]
monitoring_tool = control_value_dict.get("gpo_monitoring_tool", "")
monitoring_policy = control_value_dict.get("gpo_monitoring_policy", "")
if not monitoring_tool:
return [("", f"------ Please select a Monitoring Tool ------")]
if not monitoring_policy:
return [("", f"------ Please select a Monitoring Policy ------")]
# Add any logic to determine options based on the monitoring tool & policy.
# Some trivial exmaple logic follows.
options = [
("", f"------ Please select a Severity ------"),
("1", f"Severity 1 for {monitoring_tool} {monitoring_policy}"),
("2", f"Severity 2 for {monitoring_tool} {monitoring_policy}"),
]
return options
30 changes: 30 additions & 0 deletions how_do_i_videos/advanced_parameter_dependencies/single_control.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
def get_options_list(field, control_value=None, **kwargs):
"""
A plug-in for regenerating 'Species' options based on the value of the controlling field 'Genus'
field: This is the dependent field.
control_value: The value entered on the form for the control field. This value determines what will be displayed in "field"
"""
options = []

if control_value == '1':
options = [
("", "----- Select a Value -----"),
("A", "Value A"),
("B", "Value B"),
("C", "Value C")
]
elif control_value == '2':
options = [
("", "----- Select a Value -----"),
("D", "Value D"),
("E", "Value E"),
("F", "Value F")
]
elif control_value == '3':
options = [
("", "----- Select a Value -----"),
("G", "Value G"),
("H", "Value H"),
("I", "Value I")
]
return options