From e539f315046cc6f19b3ef80627be52b331409132 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Behmo?= Date: Thu, 17 Oct 2019 10:22:04 +0200 Subject: [PATCH] Simplify common openedx settings management Use "{% include %}" jinja directive instead of python "exec", which was a bit weird. Also, this sets the technical email for the studio, which was previous set at "technical@example.com". --- .../apps/openedx/settings/cms/development.py | 4 +--- .../apps/openedx/settings/cms/production.py | 8 +------- .../apps/openedx/settings/lms/development.py | 5 +---- .../apps/openedx/settings/lms/production.py | 17 +---------------- .../openedx/settings/partials/common/all.py | 12 ++++++++++++ .../{cms/common.py => partials/common/cms.py} | 6 ++++++ .../{lms/common.py => partials/common/lms.py} | 8 ++++++-- 7 files changed, 28 insertions(+), 32 deletions(-) create mode 100644 tutor/templates/apps/openedx/settings/partials/common/all.py rename tutor/templates/apps/openedx/settings/{cms/common.py => partials/common/cms.py} (90%) rename tutor/templates/apps/openedx/settings/{lms/common.py => partials/common/lms.py} (93%) diff --git a/tutor/templates/apps/openedx/settings/cms/development.py b/tutor/templates/apps/openedx/settings/cms/development.py index f27df75..6b9c8d0 100644 --- a/tutor/templates/apps/openedx/settings/cms/development.py +++ b/tutor/templates/apps/openedx/settings/cms/development.py @@ -1,9 +1,7 @@ import os from cms.envs.devstack import * - -# Execute the contents of common.py in this context -execfile(os.path.join(os.path.dirname(__file__), "common.py"), globals()) +{% include "apps/openedx/settings/partials/common/lms.py" %} # Setup correct webpack configuration file for development WEBPACK_CONFIG_PATH = "webpack.dev.config.js" diff --git a/tutor/templates/apps/openedx/settings/cms/production.py b/tutor/templates/apps/openedx/settings/cms/production.py index 4a109cb..c847081 100644 --- a/tutor/templates/apps/openedx/settings/cms/production.py +++ b/tutor/templates/apps/openedx/settings/cms/production.py @@ -1,9 +1,7 @@ import os from cms.envs.production import * - -# Execute the contents of common.py in this context -execfile(os.path.join(os.path.dirname(__file__), "common.py"), globals()) +{% include "apps/openedx/settings/partials/common/cms.py" %} ALLOWED_HOSTS = [ ENV_TOKENS.get("CMS_BASE"), @@ -12,7 +10,3 @@ ALLOWED_HOSTS = [ "localhost", "studio.localhost", ] - -DEFAULT_FROM_EMAIL = ENV_TOKENS["CONTACT_EMAIL"] -DEFAULT_FEEDBACK_EMAIL = ENV_TOKENS["CONTACT_EMAIL"] -SERVER_EMAIL = ENV_TOKENS["CONTACT_EMAIL"] diff --git a/tutor/templates/apps/openedx/settings/lms/development.py b/tutor/templates/apps/openedx/settings/lms/development.py index d8568d1..1d96046 100644 --- a/tutor/templates/apps/openedx/settings/lms/development.py +++ b/tutor/templates/apps/openedx/settings/lms/development.py @@ -1,10 +1,7 @@ import os from lms.envs.devstack import * - -# Execute the contents of common.py in this context -execfile(os.path.join(os.path.dirname(__file__), "common.py"), globals()) - +{% include "apps/openedx/settings/partials/common/cms.py" %} # Setup correct webpack configuration file for development WEBPACK_CONFIG_PATH = "webpack.dev.config.js" diff --git a/tutor/templates/apps/openedx/settings/lms/production.py b/tutor/templates/apps/openedx/settings/lms/production.py index 911e48f..aae55c5 100644 --- a/tutor/templates/apps/openedx/settings/lms/production.py +++ b/tutor/templates/apps/openedx/settings/lms/production.py @@ -1,9 +1,7 @@ import os from lms.envs.production import * - -# Execute the contents of common.py in this context -execfile(os.path.join(os.path.dirname(__file__), "common.py"), globals()) +{% include "apps/openedx/settings/partials/common/lms.py" %} ALLOWED_HOSTS = [ ENV_TOKENS.get("LMS_BASE"), @@ -19,16 +17,3 @@ SEARCH_SKIP_ENROLLMENT_START_DATE_FILTERING = True # Allow insecure oauth2 for local interaction with local containers OAUTH_ENFORCE_SECURE = False - -DEFAULT_FROM_EMAIL = ENV_TOKENS["CONTACT_EMAIL"] -DEFAULT_FEEDBACK_EMAIL = ENV_TOKENS["CONTACT_EMAIL"] -SERVER_EMAIL = ENV_TOKENS["CONTACT_EMAIL"] -TECH_SUPPORT_EMAIL = ENV_TOKENS["CONTACT_EMAIL"] -CONTACT_EMAIL = ENV_TOKENS["CONTACT_EMAIL"] -BUGS_EMAIL = ENV_TOKENS["CONTACT_EMAIL"] -UNIVERSITY_EMAIL = ENV_TOKENS["CONTACT_EMAIL"] -PRESS_EMAIL = ENV_TOKENS["CONTACT_EMAIL"] -PAYMENT_SUPPORT_EMAIL = ENV_TOKENS["CONTACT_EMAIL"] -BULK_EMAIL_DEFAULT_FROM_EMAIL = "no-reply@" + ENV_TOKENS["LMS_BASE"] -API_ACCESS_MANAGER_EMAIL = ENV_TOKENS["CONTACT_EMAIL"] -API_ACCESS_FROM_EMAIL = ENV_TOKENS["CONTACT_EMAIL"] diff --git a/tutor/templates/apps/openedx/settings/partials/common/all.py b/tutor/templates/apps/openedx/settings/partials/common/all.py new file mode 100644 index 0000000..3cd23c3 --- /dev/null +++ b/tutor/templates/apps/openedx/settings/partials/common/all.py @@ -0,0 +1,12 @@ +DEFAULT_FROM_EMAIL = ENV_TOKENS["CONTACT_EMAIL"] +DEFAULT_FEEDBACK_EMAIL = ENV_TOKENS["CONTACT_EMAIL"] +SERVER_EMAIL = ENV_TOKENS["CONTACT_EMAIL"] +TECH_SUPPORT_EMAIL = ENV_TOKENS["CONTACT_EMAIL"] +CONTACT_EMAIL = ENV_TOKENS["CONTACT_EMAIL"] +BUGS_EMAIL = ENV_TOKENS["CONTACT_EMAIL"] +UNIVERSITY_EMAIL = ENV_TOKENS["CONTACT_EMAIL"] +PRESS_EMAIL = ENV_TOKENS["CONTACT_EMAIL"] +PAYMENT_SUPPORT_EMAIL = ENV_TOKENS["CONTACT_EMAIL"] +BULK_EMAIL_DEFAULT_FROM_EMAIL = "no-reply@" + ENV_TOKENS["LMS_BASE"] +API_ACCESS_MANAGER_EMAIL = ENV_TOKENS["CONTACT_EMAIL"] +API_ACCESS_FROM_EMAIL = ENV_TOKENS["CONTACT_EMAIL"] diff --git a/tutor/templates/apps/openedx/settings/cms/common.py b/tutor/templates/apps/openedx/settings/partials/common/cms.py similarity index 90% rename from tutor/templates/apps/openedx/settings/cms/common.py rename to tutor/templates/apps/openedx/settings/partials/common/cms.py index 15745dd..f44cdf3 100644 --- a/tutor/templates/apps/openedx/settings/cms/common.py +++ b/tutor/templates/apps/openedx/settings/partials/common/cms.py @@ -1,3 +1,7 @@ +{% include "apps/openedx/settings/partials/common/all.py" %} + +######## Common CMS settings + # Load module store settings from config files update_module_store_settings(MODULESTORE, doc_store_settings=DOC_STORE_CONFIG) @@ -35,3 +39,5 @@ for folder in [LOG_DIR, MEDIA_ROOT, STATIC_ROOT_BASE]: {{ patch("openedx-common-settings") }} {{ patch("openedx-cms-common-settings") }} + +######## End of common CMS settings \ No newline at end of file diff --git a/tutor/templates/apps/openedx/settings/lms/common.py b/tutor/templates/apps/openedx/settings/partials/common/lms.py similarity index 93% rename from tutor/templates/apps/openedx/settings/lms/common.py rename to tutor/templates/apps/openedx/settings/partials/common/lms.py index 54e590b..5ad2504 100644 --- a/tutor/templates/apps/openedx/settings/lms/common.py +++ b/tutor/templates/apps/openedx/settings/partials/common/lms.py @@ -1,5 +1,7 @@ -"""File with configurations for lms common between production and development. -""" +{% include "apps/openedx/settings/partials/common/all.py" %} + +######## Common LMS settings + # Load module store settings from config files update_module_store_settings(MODULESTORE, doc_store_settings=DOC_STORE_CONFIG) @@ -60,3 +62,5 @@ for folder in [LOG_DIR, MEDIA_ROOT, STATIC_ROOT_BASE, ORA2_FILEUPLOAD_ROOT]: {{ patch("openedx-common-settings") }} {{ patch("openedx-lms-common-settings") }} + +######## End of common LMS settings \ No newline at end of file