From 87e66bdc9ee051b64f02b15733166d0e7057f31b Mon Sep 17 00:00:00 2001 From: Feanil Patel Date: Tue, 9 Sep 2025 09:37:30 -0400 Subject: [PATCH 1/2] fix: Don't copy the settings twice. Since we want this setting in both the LMS and CMS, just make them in the openedx-common-settings patch instead of having two copies. --- ...ommon-settings => openedx-common-settings} | 0 .../patches/openedx-lms-common-settings | 21 ------------------- 2 files changed, 21 deletions(-) rename plugins/tutor-contrib-ltistore/tutor_ltistore/patches/{openedx-cms-common-settings => openedx-common-settings} (100%) delete mode 100644 plugins/tutor-contrib-ltistore/tutor_ltistore/patches/openedx-lms-common-settings diff --git a/plugins/tutor-contrib-ltistore/tutor_ltistore/patches/openedx-cms-common-settings b/plugins/tutor-contrib-ltistore/tutor_ltistore/patches/openedx-common-settings similarity index 100% rename from plugins/tutor-contrib-ltistore/tutor_ltistore/patches/openedx-cms-common-settings rename to plugins/tutor-contrib-ltistore/tutor_ltistore/patches/openedx-common-settings diff --git a/plugins/tutor-contrib-ltistore/tutor_ltistore/patches/openedx-lms-common-settings b/plugins/tutor-contrib-ltistore/tutor_ltistore/patches/openedx-lms-common-settings deleted file mode 100644 index 4b4d7c7..0000000 --- a/plugins/tutor-contrib-ltistore/tutor_ltistore/patches/openedx-lms-common-settings +++ /dev/null @@ -1,21 +0,0 @@ - -# Add the lti store filter to the filter list, creating the configuration if it doesn't -# exist but updating it if it does exist. - -_filter_name = 'org.openedx.xblock.lti_consumer.configuration.listed.v1' - -# Get or create the filter and pipeline list for the filter we care about -_filter_to_update = OPEN_EDX_FILTERS_CONFIG.get(_filter_name, {}) -_pipeline_list = _filter_to_update.get('pipeline', []) - -# Update the list to add our new filter. -_pipeline_list.append('lti_store.pipelines.GetLtiConfigurations') - -# Replace the existing setting with the updated version from the bottom up. -# We do this because we might have created the object via the gets above. In -# which case, the parent object would not have a reference to it. -_filter_to_update['pipeline'] = _pipeline_list -# Just override this, we don't care if it's there or not. -_filter_to_update['fail_silently'] = False -OPEN_EDX_FILTERS_CONFIG[_filter_name] = _filter_to_update - From 53ea46d8e405b52376eeaa57bf7ea25884ea97e8 Mon Sep 17 00:00:00 2001 From: Feanil Patel Date: Tue, 9 Sep 2025 10:18:12 -0400 Subject: [PATCH 2/2] 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. --- .../patches/openedx-common-settings | 26 ++++++++----------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/plugins/tutor-contrib-ltistore/tutor_ltistore/patches/openedx-common-settings b/plugins/tutor-contrib-ltistore/tutor_ltistore/patches/openedx-common-settings index 4b4d7c7..cd78592 100644 --- a/plugins/tutor-contrib-ltistore/tutor_ltistore/patches/openedx-common-settings +++ b/plugins/tutor-contrib-ltistore/tutor_ltistore/patches/openedx-common-settings @@ -1,21 +1,17 @@ # Add the lti store filter to the filter list, creating the configuration if it doesn't # exist but updating it if it does exist. - _filter_name = 'org.openedx.xblock.lti_consumer.configuration.listed.v1' +_step_name = 'lti_store.pipelines.GetLtiConfigurations' -# Get or create the filter and pipeline list for the filter we care about -_filter_to_update = OPEN_EDX_FILTERS_CONFIG.get(_filter_name, {}) -_pipeline_list = _filter_to_update.get('pipeline', []) - -# Update the list to add our new filter. -_pipeline_list.append('lti_store.pipelines.GetLtiConfigurations') - -# Replace the existing setting with the updated version from the bottom up. -# We do this because we might have created the object via the gets above. In -# which case, the parent object would not have a reference to it. -_filter_to_update['pipeline'] = _pipeline_list -# Just override this, we don't care if it's there or not. -_filter_to_update['fail_silently'] = False -OPEN_EDX_FILTERS_CONFIG[_filter_name] = _filter_to_update +try: + not OPEN_EDX_FILTERS_CONFIG +except NameError: # OPEN_EDX_FILTERS_CONFIG is not defined + OPEN_EDX_FILTERS_CONFIG = {} +if not OPEN_EDX_FILTERS_CONFIG.get(_filter_name): + OPEN_EDX_FILTERS_CONFIG[_filter_name] = { + "fail_silently": False, + "pipeline": [], + } +OPEN_EDX_FILTERS_CONFIG[_filter_name]["pipeline"].append(_step_name)