From 0ed58010f1a7b8fba99a5d34cf21df320565a060 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Behmo?= Date: Wed, 6 Dec 2023 17:42:34 +0100 Subject: [PATCH] chore: remove deprecated settings ECOMMERCE_MFE_APP and ECOMMERCE_PAYMENT_MFE_APP where obsolete since Palm. --- .../patches/openedx-lms-development-settings | 6 ++++- .../patches/openedx-lms-production-settings | 2 +- tutorecommerce/plugin.py | 23 ------------------- .../apps/ecommerce/settings/development.py | 14 +++++++---- .../templates/ecommerce/tasks/ecommerce/init | 8 +++++-- 5 files changed, 21 insertions(+), 32 deletions(-) diff --git a/tutorecommerce/patches/openedx-lms-development-settings b/tutorecommerce/patches/openedx-lms-development-settings index 9f38689e..4079bfcd 100644 --- a/tutorecommerce/patches/openedx-lms-development-settings +++ b/tutorecommerce/patches/openedx-lms-development-settings @@ -1,6 +1,10 @@ # Ecommerce +{% for app_name, app in iter_mfes() %} +{% if app_name == "orders" %} ECOMMERCE_PUBLIC_URL_ROOT = "http://{{ ECOMMERCE_HOST }}:8130" ECOMMERCE_API_URL = ECOMMERCE_PUBLIC_URL_ROOT + "/api/v2" -ORDER_HISTORY_MICROFRONTEND_URL = "http://{{ MFE_HOST }}:{{ ECOMMERCE_MFE_APP['port'] }}/{{ ECOMMERCE_MFE_APP['name'] }}/orders" +ORDER_HISTORY_MICROFRONTEND_URL = "http://{{ MFE_HOST }}:{{ app['port'] }}/{{ app_name }}/orders" MFE_CONFIG["ECOMMERCE_BASE_URL"] = ECOMMERCE_PUBLIC_URL_ROOT MFE_CONFIG["ORDER_HISTORY_URL"] = ORDER_HISTORY_MICROFRONTEND_URL +{% endif %} +{% endfor %} diff --git a/tutorecommerce/patches/openedx-lms-production-settings b/tutorecommerce/patches/openedx-lms-production-settings index 36eb632a..61116c6e 100644 --- a/tutorecommerce/patches/openedx-lms-production-settings +++ b/tutorecommerce/patches/openedx-lms-production-settings @@ -1,6 +1,6 @@ # Ecommerce ECOMMERCE_PUBLIC_URL_ROOT = "{% if ENABLE_HTTPS %}https{% else %}http{% endif %}://{{ ECOMMERCE_HOST }}" ECOMMERCE_API_URL = ECOMMERCE_PUBLIC_URL_ROOT + "/api/v2" -ORDER_HISTORY_MICROFRONTEND_URL = "{% if ENABLE_HTTPS %}https{% else %}http{% endif %}://{{ MFE_HOST }}/{{ ECOMMERCE_MFE_APP['name'] }}/orders" +ORDER_HISTORY_MICROFRONTEND_URL = "{% if ENABLE_HTTPS %}https{% else %}http{% endif %}://{{ MFE_HOST }}/orders/orders" MFE_CONFIG["ECOMMERCE_BASE_URL"] = ECOMMERCE_PUBLIC_URL_ROOT MFE_CONFIG["ORDER_HISTORY_URL"] = ORDER_HISTORY_MICROFRONTEND_URL diff --git a/tutorecommerce/plugin.py b/tutorecommerce/plugin.py index a8d0cedf..989858fb 100644 --- a/tutorecommerce/plugin.py +++ b/tutorecommerce/plugin.py @@ -31,29 +31,6 @@ "OAUTH2_KEY_SSO": "ecommerce-sso", "OAUTH2_KEY_SSO_DEV": "ecommerce-sso-dev", "WORKER_JWT_ISSUER": "ecommerce-worker", # TODO do we need to keep this? - # Micro frontend applications - "MFE_APP": { - "name": "orders", - "repository": "https://github.com/edx/frontend-app-ecommerce", - "port": 1996, - }, - "PAYMENT_MFE_APP": { - "name": "payment", - "repository": "https://github.com/edx/frontend-app-payment", - "port": 1998, - "env": { - "production": { - # Hardcoded in edx-platform - "CURRENCY_COOKIE_NAME": "edx-price-l10n", - # TODO set customizable value - "CYBERSOURCE_URL": "https://testsecureacceptance.cybersource.com/silent/pay", - "SUPPORT_URL": "{% if ENABLE_HTTPS %}https{% else %}http{% endif %}://{{ LMS_HOST }}/support", - }, - "development": { - "SUPPORT_URL": "http://{{ LMS_HOST }}:8000/support", - }, - }, - }, }, "unique": { "MYSQL_PASSWORD": "{{ 8|random_string }}", diff --git a/tutorecommerce/templates/ecommerce/apps/ecommerce/settings/development.py b/tutorecommerce/templates/ecommerce/apps/ecommerce/settings/development.py index bf5a0cfa..30542e10 100644 --- a/tutorecommerce/templates/ecommerce/apps/ecommerce/settings/development.py +++ b/tutorecommerce/templates/ecommerce/apps/ecommerce/settings/development.py @@ -2,11 +2,15 @@ {% include "ecommerce/apps/ecommerce/settings/partials/common.py" %} -CORS_ORIGIN_WHITELIST = list(CORS_ORIGIN_WHITELIST) + [ - "http://{{ MFE_HOST }}:{{ ECOMMERCE_MFE_APP['port'] }}", - "http://{{ MFE_HOST }}:{{ ECOMMERCE_PAYMENT_MFE_APP['port'] }}", -] -CSRF_TRUSTED_ORIGINS = ["{{ MFE_HOST }}:{{ ECOMMERCE_MFE_APP['port'] }}"] +CORS_ORIGIN_WHITELIST = list(CORS_ORIGIN_WHITELIST) +{% for app_name, app in iter_mfes() %} +{% if app_name == "orders" %} +CORS_ORIGIN_WHITELIST.append("http://{{ MFE_HOST }}:{{ app['port'] }}") +CSRF_TRUSTED_ORIGINS = ["{{ MFE_HOST }}:{{ app['port'] }}"] +{% elif app_name == "payment" %} +CORS_ORIGIN_WHITELIST.append("http://{{ MFE_HOST }}:{{ app['port'] }}") +{% endif %} +{% endfor %} SOCIAL_AUTH_EDX_OAUTH2_PUBLIC_URL_ROOT = "http://{{ LMS_HOST }}:8000" diff --git a/tutorecommerce/templates/ecommerce/tasks/ecommerce/init b/tutorecommerce/templates/ecommerce/tasks/ecommerce/init index 7de70b11..9219b9a3 100644 --- a/tutorecommerce/templates/ecommerce/tasks/ecommerce/init +++ b/tutorecommerce/templates/ecommerce/tasks/ecommerce/init @@ -1,6 +1,8 @@ ./manage.py migrate --noinput ./manage.py oscar_populate_countries --initial-only +{% for app in iter_mfes() %} +{% if app["name"] == "payment" %} ./manage.py create_or_update_site \ --site-id=1 \ --site-domain={{ ECOMMERCE_HOST }}:8130 \ @@ -19,7 +21,7 @@ --payment-support-url="http://{{ LMS_HOST }}:8000/support" \ --discovery_api_url=http://{{ DISCOVERY_HOST }}:8381/api/v1/ \ --enable-microfrontend-for-basket-page=true \ - --payment-microfrontend-url="http://{{ MFE_HOST }}:{{ ECOMMERCE_PAYMENT_MFE_APP['port'] }}/{{ ECOMMERCE_PAYMENT_MFE_APP['name'] }}" + --payment-microfrontend-url="http://{{ MFE_HOST }}:{{ app['port'] }}/{{ app['name'] }}" # Production site ./manage.py create_or_update_site \ @@ -41,7 +43,9 @@ --payment-support-url="{% if ENABLE_HTTPS %}https{% else %}http{% endif %}://{{ LMS_HOST }}/support" \ --discovery_api_url={% if ENABLE_HTTPS %}https{% else %}http{% endif %}://{{ DISCOVERY_HOST }}/api/v1/ \ --enable-microfrontend-for-basket-page=true \ - --payment-microfrontend-url="{% if ENABLE_HTTPS %}https{% else %}http{% endif %}://{{ MFE_HOST }}/{{ ECOMMERCE_PAYMENT_MFE_APP['name'] }}" + --payment-microfrontend-url="{% if ENABLE_HTTPS %}https{% else %}http{% endif %}://{{ MFE_HOST }}/{{ app['name'] }}" +{% endif %} +{% endfor %} if [ ! -e /openedx/ecommerce/node_modules ] then