Skip to content

Commit 53ea46d

Browse files
committed
fix: Simplify and better safeguard settings patch.
Handle the case where the OPEN_EDX_FILTERS_CONFIG setting might not exist and simplify the code for adding/updating the new step to the correct pipeline.
1 parent 87e66bd commit 53ea46d

File tree

1 file changed

+11
-15
lines changed

1 file changed

+11
-15
lines changed
Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,17 @@
11

22
# Add the lti store filter to the filter list, creating the configuration if it doesn't
33
# exist but updating it if it does exist.
4-
54
_filter_name = 'org.openedx.xblock.lti_consumer.configuration.listed.v1'
5+
_step_name = 'lti_store.pipelines.GetLtiConfigurations'
66

7-
# Get or create the filter and pipeline list for the filter we care about
8-
_filter_to_update = OPEN_EDX_FILTERS_CONFIG.get(_filter_name, {})
9-
_pipeline_list = _filter_to_update.get('pipeline', [])
10-
11-
# Update the list to add our new filter.
12-
_pipeline_list.append('lti_store.pipelines.GetLtiConfigurations')
13-
14-
# Replace the existing setting with the updated version from the bottom up.
15-
# We do this because we might have created the object via the gets above. In
16-
# which case, the parent object would not have a reference to it.
17-
_filter_to_update['pipeline'] = _pipeline_list
18-
# Just override this, we don't care if it's there or not.
19-
_filter_to_update['fail_silently'] = False
20-
OPEN_EDX_FILTERS_CONFIG[_filter_name] = _filter_to_update
7+
try:
8+
not OPEN_EDX_FILTERS_CONFIG
9+
except NameError: # OPEN_EDX_FILTERS_CONFIG is not defined
10+
OPEN_EDX_FILTERS_CONFIG = {}
2111

12+
if not OPEN_EDX_FILTERS_CONFIG.get(_filter_name):
13+
OPEN_EDX_FILTERS_CONFIG[_filter_name] = {
14+
"fail_silently": False,
15+
"pipeline": [],
16+
}
17+
OPEN_EDX_FILTERS_CONFIG[_filter_name]["pipeline"].append(_step_name)

0 commit comments

Comments
 (0)