diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0c81741560..22dccd922b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -77,21 +77,21 @@ jobs: ./scripts/test/python_tests.sh env: DATABASE_URL: postgres://postgres:postgres@localhost:5432/postgres # pragma: allowlist secret - MITOPEN_SECURE_SSL_REDIRECT: "False" - MITOPEN_DB_DISABLE_SSL: "True" - MITOPEN_FEATURES_DEFAULT: "True" + MITOL_SECURE_SSL_REDIRECT: "False" + MITOL_DB_DISABLE_SSL: "True" + MITOL_FEATURES_DEFAULT: "True" OPENSEARCH_URL: localhost:9200 CELERY_TASK_ALWAYS_EAGER: "True" CELERY_BROKER_URL: redis://localhost:6379/4 CELERY_RESULT_BACKEND: redis://localhost:6379/4 TIKA_CLIENT_ONLY: "True" - MITOPEN_APP_BASE_URL: http://localhost:8062/ + MITOL_APP_BASE_URL: http://localhost:8062/ MAILGUN_KEY: fake_mailgun_key MAILGUN_SENDER_DOMAIN: other.fake.site OPENSEARCH_INDEX: testindex INDEXING_API_USERNAME: mitodl - MITOPEN_COOKIE_DOMAIN: localhost - MITOPEN_COOKIE_NAME: cookie_monster + MITOL_COOKIE_DOMAIN: localhost + MITOL_COOKIE_NAME: cookie_monster - name: Upload coverage to CodeCov uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # v4.5.0 @@ -126,7 +126,7 @@ jobs: - name: Webpack build run: yarn run build env: - MITOPEN_API_BASE_URL: https://api.mitopen-test.odl.mit.edu + MITOL_API_BASE_URL: https://api.mitlearn-test.odl.mit.edu - name: Lints run: yarn run lint-check diff --git a/Procfile b/Procfile index e7f09048ac..371ac3be5f 100644 --- a/Procfile +++ b/Procfile @@ -1,5 +1,5 @@ release: bash scripts/heroku-release-phase.sh web: bin/start-nginx bin/start-pgbouncer newrelic-admin run-program uwsgi uwsgi.ini -worker: bin/start-pgbouncer newrelic-admin run-program celery -A main.celery:app worker -E -Q default --concurrency=2 -B -l $MITOPEN_LOG_LEVEL -extra_worker_2x: bin/start-pgbouncer newrelic-admin run-program celery -A main.celery:app worker -E -Q edx_content,default --concurrency=2 -l $MITOPEN_LOG_LEVEL -extra_worker_performance: bin/start-pgbouncer newrelic-admin run-program celery -A main.celery:app worker -E -Q edx_content,default -l $MITOPEN_LOG_LEVEL +worker: bin/start-pgbouncer newrelic-admin run-program celery -A main.celery:app worker -E -Q default --concurrency=2 -B -l $MITOL_LOG_LEVEL +extra_worker_2x: bin/start-pgbouncer newrelic-admin run-program celery -A main.celery:app worker -E -Q edx_content,default --concurrency=2 -l $MITOL_LOG_LEVEL +extra_worker_performance: bin/start-pgbouncer newrelic-admin run-program celery -A main.celery:app worker -E -Q edx_content,default -l $MITOL_LOG_LEVEL diff --git a/README.md b/README.md index 836160a041..0c59e63a2e 100644 --- a/README.md +++ b/README.md @@ -134,7 +134,7 @@ Article posts give users the option to upload a cover image, and we show a thumb image in post listings. We use Embedly to generate that thumbnail, so they will appear as broken images unless you configure your app to upload to S3. Steps: -1. Set `MITOPEN_USE_S3=True` in `.env` +1. Set `MITOL_USE_S3=True` in `.env` 1. Also in `.env`, set these AWS variables: `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, `AWS_STORAGE_BUCKET_NAME` @@ -222,8 +222,8 @@ Once these are set (and you've restarted the app), you should see events flowing A Javascript bundle of exported frontend components can be generated for use in external websites that have CORS allowance into a given instance of `mit-open`. There are a few settings you might want to change in order to get the expected results. -- `MITOPEN_AXIOS_WITH_CREDENTIALS` - This sets `withCredentials: true` when initializing the Axios API, which tells the end user's browser to send along any browser level cookies for the current domain when making CORS requests -- `MITOPEN_API_BASE_URL` - This sets the base url used for API requests, which will need to be set to a fully qualified url pointing to an instance of `mit-open` (i.e. https://learn.mit.edu) in order for requests from the external site to reach the proper destination +- `MITOL_AXIOS_WITH_CREDENTIALS` - This sets `withCredentials: true` when initializing the Axios API, which tells the end user's browser to send along any browser level cookies for the current domain when making CORS requests +- `MITOL_API_BASE_URL` - This sets the base url used for API requests, which will need to be set to a fully qualified url pointing to an instance of `mit-open` (i.e. https://learn.mit.edu) in order for requests from the external site to reach the proper destination - `CORS_ALLOWED_ORIGINS`, `CSRF_TRUSTED_ORIGINS` - On the instance of `mit-open` that the externally hosted components will access via the API, the domains of any sites that need CORS access need to be here as a list of strings To build the bundle of exported components, run: diff --git a/RELEASE.rst b/RELEASE.rst index 35fd5668b3..8d042937a4 100644 --- a/RELEASE.rst +++ b/RELEASE.rst @@ -384,7 +384,7 @@ Version 0.13.2 (Released June 13, 2024) -------------- - Update education options and add to schema (#1069) -- local dev: Read `MITOPEN_AXIOS_BASE_PATH` from env (#1065) +- local dev: Read `MITOL_AXIOS_BASE_PATH` from env (#1065) - Add featured courses carousel to unit channel page (#1059) - Add ordering to testimonials, adjust view on homepage testimonial carousel (#1067) - Change channel type and url from "offeror" to "unit" (#1031) diff --git a/app.json b/app.json index d4e43ecf3d..c9c73b75cb 100644 --- a/app.json +++ b/app.json @@ -285,92 +285,92 @@ "description": "Base default URL for OLL courses", "required": false }, - "MITOPEN_ADMIN_EMAIL": { + "MITOL_ADMIN_EMAIL": { "description": "E-mail to send 500 reports to." }, - "MITOPEN_AUTHENTICATION_PLUGINS": { + "MITOL_AUTHENTICATION_PLUGINS": { "description": "List of pluggy plugins to use for authentication", "required": false }, - "MITOPEN_LEARNING_RESOURCES_PLUGINS": { + "MITOL_LEARNING_RESOURCES_PLUGINS": { "description": "List of pluggy plugins to use for learning resources", "required": false }, - "MITOPEN_APP_BASE_URL": { + "MITOL_APP_BASE_URL": { "description": "Base url to create links to the app" }, - "MITOPEN_COOKIE_NAME": { + "MITOL_COOKIE_NAME": { "description": "Name of the cookie for the JWT auth token" }, - "MITOPEN_COOKIE_DOMAIN": { + "MITOL_COOKIE_DOMAIN": { "description": "Domain for the cookie for the JWT auth token" }, - "MITOPEN_DB_CONN_MAX_AGE": { + "MITOL_DB_CONN_MAX_AGE": { "value": "0" }, - "MITOPEN_DB_DISABLE_SSL": { + "MITOL_DB_DISABLE_SSL": { "value": "True" }, - "MITOPEN_DB_DISABLE_SS_CURSORS": { + "MITOL_DB_DISABLE_SS_CURSORS": { "description": "Disable server-side cursors", "required": false }, - "MITOPEN_EMAIL_HOST": { + "MITOL_EMAIL_HOST": { "description": "Outgoing e-mail settings" }, - "MITOPEN_EMAIL_PASSWORD": { + "MITOL_EMAIL_PASSWORD": { "description": "Outgoing e-mail settings" }, - "MITOPEN_EMAIL_PORT": { + "MITOL_EMAIL_PORT": { "description": "Outgoing e-mail settings", "value": "587" }, - "MITOPEN_EMAIL_TLS": { + "MITOL_EMAIL_TLS": { "description": "Outgoing e-mail settings", "value": "True" }, - "MITOPEN_EMAIL_USER": { + "MITOL_EMAIL_USER": { "description": "Outgoing e-mail settings" }, - "MITOPEN_ENVIRONMENT": { + "MITOL_ENVIRONMENT": { "description": "The execution environment that the app is in (e.g. dev, staging, prod)" }, - "MITOPEN_FROM_EMAIL": { + "MITOL_FROM_EMAIL": { "description": "E-mail to use for the from field" }, - "MITOPEN_LOG_LEVEL": { + "MITOL_LOG_LEVEL": { "description": "The log level for the application", "required": true, "value": "INFO" }, - "MITOPEN_NEW_USER_LOGIN_URL": { + "MITOL_NEW_USER_LOGIN_URL": { "description": "Url to redirect new users to", "required": false }, - "MITOPEN_JWT_SECRET": { + "MITOL_JWT_SECRET": { "description": "Shared secret for JWT auth tokens", "required": true }, - "MITOPEN_SECURE_SSL_REDIRECT": { + "MITOL_SECURE_SSL_REDIRECT": { "description": "Application-level SSL redirect setting.", "value": "True" }, - "MITOPEN_SIMILAR_RESOURCES_COUNT": { + "MITOL_SIMILAR_RESOURCES_COUNT": { "description": "Number of similar resources to return", "required": false }, - "MITOPEN_TITLE": { + "MITOL_TITLE": { "description": "Title of the MIT Open site", "required": false }, - "MITOPEN_SUPPORT_EMAIL": { + "MITOL_SUPPORT_EMAIL": { "description": "Email address listed for customer support" }, - "MITOPEN_UNSUBSCRIBE_TOKEN_MAX_AGE_SECONDS": { + "MITOL_UNSUBSCRIBE_TOKEN_MAX_AGE_SECONDS": { "description": "Maximum age of unsubscribe tokens in seconds", "required": false }, - "MITOPEN_USE_S3": { + "MITOL_USE_S3": { "description": "Use S3 for storage backend (required on Heroku)", "value": "False" }, diff --git a/authentication/hooks.py b/authentication/hooks.py index f3d67b8729..250e8c9261 100644 --- a/authentication/hooks.py +++ b/authentication/hooks.py @@ -25,7 +25,7 @@ def get_plugin_manager(): """Return the plugin manager for authentication hooks""" pm = pluggy.PluginManager(app_config.name) pm.add_hookspecs(AuthenticationHooks) - for module in settings.MITOPEN_AUTHENTICATION_PLUGINS.split(","): + for module in settings.MITOL_AUTHENTICATION_PLUGINS.split(","): if module: plugin_cls = import_string(module) pm.register(plugin_cls()) diff --git a/docker-compose-notebook.yml b/docker-compose-notebook.yml index dd95a6e786..f3473bad7d 100644 --- a/docker-compose-notebook.yml +++ b/docker-compose-notebook.yml @@ -5,9 +5,9 @@ x-environment: &py-environment DEV_ENV: "True" # necessary to have nginx connect to web container NODE_ENV: "production" DATABASE_URL: postgres://postgres:postgres@db:5432/postgres # pragma: allowlist secret - MITOPEN_SECURE_SSL_REDIRECT: "False" - MITOPEN_DB_DISABLE_SSL: "True" - MITOPEN_FEATURES_DEFAULT: "True" + MITOL_SECURE_SSL_REDIRECT: "False" + MITOL_DB_DISABLE_SSL: "True" + MITOL_FEATURES_DEFAULT: "True" OPENSEARCH_URL: elastic:9200 CELERY_TASK_ALWAYS_EAGER: "False" CELERY_BROKER_URL: redis://redis:6379/4 diff --git a/docker-compose.yml b/docker-compose.yml index 7cb3b3aa6e..26beb335e9 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -135,8 +135,8 @@ services: command: > /bin/bash -c ' sleep 3; - celery -A main.celery:app worker -Q default -B -l ${MITOPEN_LOG_LEVEL:-INFO} & - celery -A main.celery:app worker -Q edx_content,default -l ${MITOPEN_LOG_LEVEL:-INFO}' + celery -A main.celery:app worker -Q default -B -l ${MITOL_LOG_LEVEL:-INFO} & + celery -A main.celery:app worker -Q edx_content,default -l ${MITOL_LOG_LEVEL:-INFO}' links: - db - opensearch-node-mitopen diff --git a/env/backend.env b/env/backend.env index 0ed73a7b1d..3bff0e459a 100644 --- a/env/backend.env +++ b/env/backend.env @@ -7,8 +7,8 @@ CORS_ALLOWED_ORIGINS='["http://open.odl.local:8062"]' CSRF_TRUSTED_ORIGINS='["http://open.odl.local:8062", "http://api.open.odl.local:8063"]' CSRF_COOKIE_DOMAIN=open.odl.local CSRF_COOKIE_SECURE=False -MITOPEN_COOKIE_DOMAIN=open.odl.local -MITOPEN_COOKIE_NAME=discussions +MITOL_COOKIE_DOMAIN=open.odl.local +MITOL_COOKIE_NAME=discussions DEBUG=True @@ -18,9 +18,9 @@ DEV_ENV=true DATABASE_URL=postgres://postgres:postgres@db:5432/postgres -MITOPEN_DB_DISABLE_SSL=True -MITOPEN_FEATURES_DEFAULT=True -MITOPEN_SECURE_SSL_REDIRECT=False +MITOL_DB_DISABLE_SSL=True +MITOL_FEATURES_DEFAULT=True +MITOL_SECURE_SSL_REDIRECT=False OPENSEARCH_URL=opensearch-node-mitopen:9200 OPENSEARCH_INDEX=discussions_local diff --git a/env/backend.local.example.env b/env/backend.local.example.env index 3180b3bd70..c9cb02854f 100644 --- a/env/backend.local.example.env +++ b/env/backend.local.example.env @@ -1,5 +1,5 @@ -# MITOPEN_JWT_SECRET= -# MITOPEN_USE_S3=True +# MITOL_JWT_SECRET= +# MITOL_USE_S3=True # MAILGUN_SENDER_DOMAIN= # MAILGUN_KEY= # MAILGUN_RECIPIENT_OVERRIDE= diff --git a/env/ci.env b/env/ci.env index d86ad0ff77..58a36aa3a2 100644 --- a/env/ci.env +++ b/env/ci.env @@ -2,17 +2,17 @@ NODE_ENV=production DEV_ENV=True DATABASE_URL=postgres://postgres:postgres@db:5432/e2e_postgres # pragma: allowlist secret -MITOPEN_SECURE_SSL_REDIRECT=False -MITOPEN_DB_DISABLE_SSL=True -MITOPEN_FEATURES_DEFAULT=True +MITOL_SECURE_SSL_REDIRECT=False +MITOL_DB_DISABLE_SSL=True +MITOL_FEATURES_DEFAULT=True OPENSEARCH_URL=opensearch-node-mitopen:9200 CELERY_TASK_ALWAYS_EAGER=False CELERY_BROKER_URL=redis://redis:6379/4 CELERY_RESULT_BACKEND=redis://redis:6379/4 TIKA_CLIENT_ONLY=True -MITOPEN_APP_BASE_URL=http://localhost:8063/ +MITOL_APP_BASE_URL=http://localhost:8063/ MAILGUN_KEY=fake_mailgun_key MAILGUN_SENDER_DOMAIN=other.fake.site OPENSEARCH_INDEX=testindex -MITOPEN_COOKIE_DOMAIN=localhost -MITOPEN_COOKIE_NAME=cookie_monster +MITOL_COOKIE_DOMAIN=localhost +MITOL_COOKIE_NAME=cookie_monster diff --git a/env/frontend.env b/env/frontend.env index a6adf9277f..bb2ea22390 100644 --- a/env/frontend.env +++ b/env/frontend.env @@ -1,3 +1,3 @@ NODE_ENV=development PORT=8062 -MITOPEN_AXIOS_WITH_CREDENTIALS=true +MITOL_AXIOS_WITH_CREDENTIALS=true diff --git a/env/shared.env b/env/shared.env index 67c604a1df..8c04146dcf 100644 --- a/env/shared.env +++ b/env/shared.env @@ -1,5 +1,5 @@ -MITOPEN_API_BASE_URL=http://api.open.odl.local:8063 -MITOPEN_APP_BASE_URL=http://open.odl.local:8062 -MITOPEN_SUPPORT_EMAIL=support@localhost +MITOL_API_BASE_URL=http://api.open.odl.local:8063 +MITOL_APP_BASE_URL=http://open.odl.local:8062 +MITOL_SUPPORT_EMAIL=support@localhost POSTHOG_TIMEOUT_MS=1500 diff --git a/env/shared.local.example.env b/env/shared.local.example.env index c18b9bdde5..5e378f125a 100644 --- a/env/shared.local.example.env +++ b/env/shared.local.example.env @@ -1,5 +1,5 @@ -# MITOPEN_API_BASE_URL=http://api.open.odl.local:8063 -# MITOPEN_APP_BASE_URL=http://open.odl.local:8063 +# MITOL_API_BASE_URL=http://api.open.odl.local:8063 +# MITOL_APP_BASE_URL=http://open.odl.local:8063 # POSTHOG_PROJECT_API_KEY= # POSTHOG_TIMEOUT_MS=1500 # EMBEDLY_KEY= diff --git a/fixtures/users.py b/fixtures/users.py index 60e40ba74c..6e96b5ca91 100644 --- a/fixtures/users.py +++ b/fixtures/users.py @@ -51,8 +51,8 @@ def jwt_token(db, user, client, rf, settings): # noqa: ARG001 jwt_encode_handler = api_settings.JWT_ENCODE_HANDLER payload = jwt_payload_handler(user) token = jwt_encode_handler(payload) - client.cookies[settings.MITOPEN_COOKIE_NAME] = token - rf.cookies.load({settings.MITOPEN_COOKIE_NAME: token}) + client.cookies[settings.MITOL_COOKIE_NAME] = token + rf.cookies.load({settings.MITOL_COOKIE_NAME: token}) return token diff --git a/frontends/api/jest.config.ts b/frontends/api/jest.config.ts index fa929ee93d..e0c1ce9c88 100644 --- a/frontends/api/jest.config.ts +++ b/frontends/api/jest.config.ts @@ -9,8 +9,8 @@ const config: Config.InitialOptions = { ], globals: { APP_SETTINGS: { - MITOPEN_AXIOS_WITH_CREDENTIALS: false, - MITOPEN_API_BASE_URL: "https://api.test.learn.mit.edu", + MITOL_AXIOS_WITH_CREDENTIALS: false, + MITOL_API_BASE_URL: "https://api.test.learn.mit.edu", }, }, } diff --git a/frontends/api/src/axios.ts b/frontends/api/src/axios.ts index bdbe07e8be..47f405bc46 100644 --- a/frontends/api/src/axios.ts +++ b/frontends/api/src/axios.ts @@ -7,7 +7,7 @@ const instance = axios.create({ xsrfCookieName: "csrftoken", xsrfHeaderName: "X-CSRFToken", withXSRFToken: true, - withCredentials: APP_SETTINGS.MITOPEN_AXIOS_WITH_CREDENTIALS, + withCredentials: APP_SETTINGS.MITOL_AXIOS_WITH_CREDENTIALS, }) export default instance diff --git a/frontends/api/src/clients.ts b/frontends/api/src/clients.ts index f3500fafab..2f4781910c 100644 --- a/frontends/api/src/clients.ts +++ b/frontends/api/src/clients.ts @@ -24,9 +24,9 @@ import { import axiosInstance from "./axios" -const { MITOPEN_API_BASE_URL } = APP_SETTINGS +const { MITOL_API_BASE_URL } = APP_SETTINGS -const BASE_PATH = MITOPEN_API_BASE_URL?.replace(/\/+$/, "") ?? "" +const BASE_PATH = MITOL_API_BASE_URL?.replace(/\/+$/, "") ?? "" const learningResourcesApi = new LearningResourcesApi( undefined, diff --git a/frontends/api/src/test-utils/urls.ts b/frontends/api/src/test-utils/urls.ts index 3f608c939a..c4ca6079db 100644 --- a/frontends/api/src/test-utils/urls.ts +++ b/frontends/api/src/test-utils/urls.ts @@ -26,7 +26,7 @@ import type { import type { BaseAPI } from "../generated/v1/base" import type { BaseAPI as BaseAPIv0 } from "../generated/v0/base" -const { MITOPEN_API_BASE_URL: API_BASE_URL } = APP_SETTINGS +const { MITOL_API_BASE_URL: API_BASE_URL } = APP_SETTINGS // OpenAPI Generator declares parameters using interfaces, which makes passing // them to functions a little annoying. diff --git a/frontends/api/src/types/settings.d.ts b/frontends/api/src/types/settings.d.ts index 0354c84532..1c5077eee0 100644 --- a/frontends/api/src/types/settings.d.ts +++ b/frontends/api/src/types/settings.d.ts @@ -2,7 +2,7 @@ export declare global { const APP_SETTINGS: { - MITOPEN_AXIOS_WITH_CREDENTIALS?: boolean - MITOPEN_API_BASE_URL?: string + MITOL_AXIOS_WITH_CREDENTIALS?: boolean + MITOL_API_BASE_URL?: string } } diff --git a/frontends/mit-open/jest.config.ts b/frontends/mit-open/jest.config.ts index 3ed821699f..0824f93268 100644 --- a/frontends/mit-open/jest.config.ts +++ b/frontends/mit-open/jest.config.ts @@ -16,7 +16,7 @@ const config: Config.InitialOptions = { globals: { APP_SETTINGS: { EMBEDLY_KEY: "embedly_key", - MITOPEN_API_BASE_URL: "https://api.test.learn.mit.edu", + MITOL_API_BASE_URL: "https://api.test.learn.mit.edu", PUBLIC_URL: "", SITE_NAME: "MIT Open", }, diff --git a/frontends/mit-open/src/common/urls.test.ts b/frontends/mit-open/src/common/urls.test.ts index 0fbdc25aec..7e7ae66529 100644 --- a/frontends/mit-open/src/common/urls.test.ts +++ b/frontends/mit-open/src/common/urls.test.ts @@ -1,20 +1,20 @@ import { login } from "./urls" -const { MITOPEN_API_BASE_URL } = APP_SETTINGS +const { MITOL_API_BASE_URL } = APP_SETTINGS test("login encodes the next parameter appropriately", () => { expect(login()).toBe( - `${MITOPEN_API_BASE_URL}/login/ol-oidc/?next=http://localhost/`, + `${MITOL_API_BASE_URL}/login/ol-oidc/?next=http://localhost/`, ) expect(login({})).toBe( - `${MITOPEN_API_BASE_URL}/login/ol-oidc/?next=http://localhost/`, + `${MITOL_API_BASE_URL}/login/ol-oidc/?next=http://localhost/`, ) expect( login({ pathname: "/foo/bar", }), - ).toBe(`${MITOPEN_API_BASE_URL}/login/ol-oidc/?next=http://localhost/foo/bar`) + ).toBe(`${MITOL_API_BASE_URL}/login/ol-oidc/?next=http://localhost/foo/bar`) expect( login({ @@ -22,6 +22,6 @@ test("login encodes the next parameter appropriately", () => { search: "?cat=meow", }), ).toBe( - `${MITOPEN_API_BASE_URL}/login/ol-oidc/?next=http://localhost/foo/bar%3Fcat%3Dmeow`, + `${MITOL_API_BASE_URL}/login/ol-oidc/?next=http://localhost/foo/bar%3Fcat%3Dmeow`, ) }) diff --git a/frontends/mit-open/src/common/urls.ts b/frontends/mit-open/src/common/urls.ts index 750f57b1ec..3fcd5014e5 100644 --- a/frontends/mit-open/src/common/urls.ts +++ b/frontends/mit-open/src/common/urls.ts @@ -36,10 +36,10 @@ export const makeChannelManageWidgetsPath = ( name: string, ) => generatePath(CHANNEL_EDIT_WIDGETS, { channelType, name }) -const { MITOPEN_API_BASE_URL } = APP_SETTINGS +const { MITOL_API_BASE_URL } = APP_SETTINGS -export const LOGIN = `${MITOPEN_API_BASE_URL}/login/ol-oidc/` -export const LOGOUT = `${MITOPEN_API_BASE_URL}/logout/` +export const LOGIN = `${MITOL_API_BASE_URL}/login/ol-oidc/` +export const LOGOUT = `${MITOL_API_BASE_URL}/logout/` /** * Returns the URL to the login page, with a `next` parameter to redirect back diff --git a/frontends/mit-open/src/pages/PrivacyPage/PrivacyPage.tsx b/frontends/mit-open/src/pages/PrivacyPage/PrivacyPage.tsx index f3eb87bc1d..de1cb9bef9 100644 --- a/frontends/mit-open/src/pages/PrivacyPage/PrivacyPage.tsx +++ b/frontends/mit-open/src/pages/PrivacyPage/PrivacyPage.tsx @@ -52,7 +52,7 @@ const UnorderedList = styled.ul(({ theme }) => ({ ...theme.typography.body1, })) -const { SITE_NAME, MITOPEN_SUPPORT_EMAIL } = APP_SETTINGS +const { SITE_NAME, MITOL_SUPPORT_EMAIL } = APP_SETTINGS const PrivacyPage: React.FC = () => { return ( @@ -164,8 +164,8 @@ const PrivacyPage: React.FC = () => { If you have concerns about any of these purposes, or how we - communicate with you, please contact us at {MITOPEN_SUPPORT_EMAIL}. - We will always respect a request by you to stop processing your + communicate with you, please contact us at {MITOL_SUPPORT_EMAIL}. We + will always respect a request by you to stop processing your personal information (subject to our legal obligations). diff --git a/frontends/mit-open/webpack.config.js b/frontends/mit-open/webpack.config.js index 5e9797e59d..bc9bb820e1 100644 --- a/frontends/mit-open/webpack.config.js +++ b/frontends/mit-open/webpack.config.js @@ -29,13 +29,13 @@ const { NODE_ENV, PORT, VERSION, - MITOPEN_API_BASE_URL, + MITOL_API_BASE_URL, API_DEV_PROXY_BASE_URL, WEBPACK_ANALYZE, SITE_NAME, PUBLIC_URL, - MITOPEN_SUPPORT_EMAIL, - MITOPEN_AXIOS_WITH_CREDENTIALS, + MITOL_SUPPORT_EMAIL, + MITOL_AXIOS_WITH_CREDENTIALS, EMBEDLY_KEY, CKEDITOR_UPLOAD_URL, SENTRY_DSN, @@ -52,7 +52,7 @@ const { desc: "The current release version", default: "0.0.0", }), - MITOPEN_API_BASE_URL: str({ + MITOL_API_BASE_URL: str({ desc: "Base URL for API requests", devDefault: "", }), @@ -73,11 +73,11 @@ const { desc: "The site URL, for display", default: "", }), - MITOPEN_SUPPORT_EMAIL: str({ + MITOL_SUPPORT_EMAIL: str({ desc: "Email address for support", default: "mitlearn-support@mit.edu", }), - MITOPEN_AXIOS_WITH_CREDENTIALS: bool({ + MITOL_AXIOS_WITH_CREDENTIALS: bool({ desc: "Instructs the Axios API client to send credentials with requests", default: false, }), @@ -99,14 +99,14 @@ const { }), }) -const MITOPEN_FEATURES_PREFIX = "FEATURE_" +const MITOL_FEATURES_PREFIX = "FEATURE_" const getFeatureFlags = () => { const bootstrapFeatureFlags = {} for (const [key, value] of Object.entries(process.env)) { - if (key.startsWith(MITOPEN_FEATURES_PREFIX)) { - bootstrapFeatureFlags[key.replace(MITOPEN_FEATURES_PREFIX, "")] = + if (key.startsWith(MITOL_FEATURES_PREFIX)) { + bootstrapFeatureFlags[key.replace(MITOL_FEATURES_PREFIX, "")] = value === "True" ? true : JSON.stringify(value) } } @@ -211,15 +211,15 @@ module.exports = (env, argv) => { }), new webpack.DefinePlugin({ APP_SETTINGS: { - MITOPEN_AXIOS_WITH_CREDENTIALS, - MITOPEN_API_BASE_URL: JSON.stringify(MITOPEN_API_BASE_URL), + MITOL_AXIOS_WITH_CREDENTIALS, + MITOL_API_BASE_URL: JSON.stringify(MITOL_API_BASE_URL), EMBEDLY_KEY: JSON.stringify(EMBEDLY_KEY), CKEDITOR_UPLOAD_URL: JSON.stringify(CKEDITOR_UPLOAD_URL), VERSION: JSON.stringify(VERSION), SENTRY_DSN: JSON.stringify(SENTRY_DSN), POSTHOG: getPostHogSettings(), SITE_NAME: JSON.stringify(SITE_NAME), - MITOPEN_SUPPORT_EMAIL: JSON.stringify(MITOPEN_SUPPORT_EMAIL), + MITOL_SUPPORT_EMAIL: JSON.stringify(MITOL_SUPPORT_EMAIL), PUBLIC_URL: JSON.stringify(PUBLIC_URL), }, }), diff --git a/frontends/ol-ckeditor/jest.config.ts b/frontends/ol-ckeditor/jest.config.ts index 24c6c19d0f..9cc7a02b7a 100644 --- a/frontends/ol-ckeditor/jest.config.ts +++ b/frontends/ol-ckeditor/jest.config.ts @@ -15,8 +15,8 @@ const config: Config.InitialOptions = { APP_SETTINGS: { CKEDITOR_UPLOAD_URL: "https://meowmeow.com", EMBEDLY_KEY: "embedly_key", - MITOPEN_AXIOS_WITH_CREDENTIALS: false, - MITOPEN_API_BASE_URL: "https://api.test.learn.mit.edu", + MITOL_AXIOS_WITH_CREDENTIALS: false, + MITOL_API_BASE_URL: "https://api.test.learn.mit.edu", }, }, } diff --git a/frontends/ol-ckeditor/src/types/settings.d.ts b/frontends/ol-ckeditor/src/types/settings.d.ts index e3c4ebdb16..fbb37f3706 100644 --- a/frontends/ol-ckeditor/src/types/settings.d.ts +++ b/frontends/ol-ckeditor/src/types/settings.d.ts @@ -4,8 +4,8 @@ export declare global { const APP_SETTINGS: { EMBEDLY_KEY: string CKEDITOR_UPLOAD_URL?: string - MITOPEN_AXIOS_WITH_CREDENTIALS: boolean - MITOPEN_API_BASE_URL: string + MITOL_AXIOS_WITH_CREDENTIALS: boolean + MITOL_API_BASE_URL: string PUBLIC_URL: string SITE_NAME: string } diff --git a/frontends/ol-utilities/jest.config.ts b/frontends/ol-utilities/jest.config.ts index bb7d644b4c..01eaa01a8e 100644 --- a/frontends/ol-utilities/jest.config.ts +++ b/frontends/ol-utilities/jest.config.ts @@ -5,7 +5,7 @@ const config: Config.InitialOptions = { ...baseConfig, globals: { APP_SETTINGS: { - MITOPEN_API_BASE_URL: "https://api.test.learn.mit.edu", + MITOL_API_BASE_URL: "https://api.test.learn.mit.edu", }, }, } diff --git a/frontends/ol-utilities/src/types/settings.d.ts b/frontends/ol-utilities/src/types/settings.d.ts index a5da5cd142..b3544ab23a 100644 --- a/frontends/ol-utilities/src/types/settings.d.ts +++ b/frontends/ol-utilities/src/types/settings.d.ts @@ -8,8 +8,8 @@ export type PostHogSettings = { export declare global { declare const APP_SETTINGS: { - MITOPEN_AXIOS_WITH_CREDENTIALS?: boolean - MITOPEN_API_BASE_URL: string + MITOL_AXIOS_WITH_CREDENTIALS?: boolean + MITOL_API_BASE_URL: string EMBEDLY_KEY: string CKEDITOR_UPLOAD_URL?: string SENTRY_DSN?: string @@ -17,7 +17,7 @@ export declare global { SENTRY_ENV?: string POSTHOG?: PostHogSettings SITE_NAME: string - MITOPEN_SUPPORT_EMAIL: string + MITOL_SUPPORT_EMAIL: string PUBLIC_URL: string } } diff --git a/learning_resources/hooks.py b/learning_resources/hooks.py index b588f3a05f..66bb558b15 100644 --- a/learning_resources/hooks.py +++ b/learning_resources/hooks.py @@ -89,7 +89,7 @@ def get_plugin_manager(): """Return the plugin manager for learning_resources hooks""" pm = pluggy.PluginManager(app_config.name) pm.add_hookspecs(LearningResourceHooks) - for module in settings.MITOPEN_LEARNING_RESOURCES_PLUGINS.split(","): + for module in settings.MITOL_LEARNING_RESOURCES_PLUGINS.split(","): if module: plugin_cls = import_string(module) pm.register(plugin_cls()) diff --git a/main/auth_utils.py b/main/auth_utils.py index cf2fe1db6a..bae3171ba3 100644 --- a/main/auth_utils.py +++ b/main/auth_utils.py @@ -32,7 +32,7 @@ def unsign_and_verify_username_from_token(token): signer = signing.TimestampSigner() try: return signer.unsign( - token, max_age=settings.MITOPEN_UNSUBSCRIBE_TOKEN_MAX_AGE_SECONDS + token, max_age=settings.MITOL_UNSUBSCRIBE_TOKEN_MAX_AGE_SECONDS ) except signing.BadSignature: return None diff --git a/main/features.py b/main/features.py index ee661d7f35..3391885191 100644 --- a/main/features.py +++ b/main/features.py @@ -171,7 +171,7 @@ def is_enabled( return ( value if value is not None - else settings.FEATURES.get(name, default or settings.MITOPEN_FEATURES_DEFAULT) + else settings.FEATURES.get(name, default or settings.MITOL_FEATURES_DEFAULT) ) diff --git a/main/features_test.py b/main/features_test.py index 89cc3664db..07272355de 100644 --- a/main/features_test.py +++ b/main/features_test.py @@ -41,7 +41,7 @@ def test_is_enabled( ): """Tests that is_enabled returns expected values""" key = "feature_key_we_will_never_use" - settings.MITOPEN_FEATURES_DEFAULT = default_in_settings + settings.MITOL_FEATURES_DEFAULT = default_in_settings if value_in_settings is not None: settings.FEATURES[key] = value_in_settings diff --git a/main/settings.py b/main/settings.py index 81fbcc638b..301819ad2d 100644 --- a/main/settings.py +++ b/main/settings.py @@ -37,7 +37,7 @@ log = logging.getLogger() -ENVIRONMENT = get_string("MITOPEN_ENVIRONMENT", "dev") +ENVIRONMENT = get_string("MITOL_ENVIRONMENT", "dev") DEFAULT_AUTO_FIELD = "django.db.models.AutoField" # initialize Sentry before doing anything else so we capture any config errors @@ -62,14 +62,14 @@ ALLOWED_HOSTS = ["*"] -SECURE_SSL_REDIRECT = get_bool("MITOPEN_SECURE_SSL_REDIRECT", True) # noqa: FBT003 +SECURE_SSL_REDIRECT = get_bool("MITOL_SECURE_SSL_REDIRECT", True) # noqa: FBT003 SITE_ID = 1 -APP_BASE_URL = get_string("MITOPEN_APP_BASE_URL", None) +APP_BASE_URL = get_string("MITOL_APP_BASE_URL", None) if not APP_BASE_URL: - msg = "MITOPEN_APP_BASE_URL is not set" + msg = "MITOL_APP_BASE_URL is not set" raise ImproperlyConfigured(msg) -MITOPEN_TITLE = get_string("MITOPEN_TITLE", "MIT Open") +MITOL_TITLE = get_string("MITOL_TITLE", "MIT Open") # Application definition @@ -186,8 +186,8 @@ LOGOUT_URL = "/logout" LOGOUT_REDIRECT_URL = "/app" -MITOPEN_TOS_URL = get_string( - "MITOPEN_TOS_URL", urljoin(APP_BASE_URL, "/terms-and-conditions/") +MITOL_TOS_URL = get_string( + "MITOL_TOS_URL", urljoin(APP_BASE_URL, "/terms-and-conditions/") ) ROOT_URLCONF = "main.urls" @@ -227,12 +227,12 @@ ) ) DEFAULT_DATABASE_CONFIG["DISABLE_SERVER_SIDE_CURSORS"] = get_bool( - "MITOPEN_DB_DISABLE_SS_CURSORS", + "MITOL_DB_DISABLE_SS_CURSORS", True, # noqa: FBT003 ) -DEFAULT_DATABASE_CONFIG["CONN_MAX_AGE"] = get_int("MITOPEN_DB_CONN_MAX_AGE", 0) +DEFAULT_DATABASE_CONFIG["CONN_MAX_AGE"] = get_int("MITOL_DB_CONN_MAX_AGE", 0) -if get_bool("MITOPEN_DB_DISABLE_SSL", False): # noqa: FBT003 +if get_bool("MITOL_DB_DISABLE_SSL", False): # noqa: FBT003 DEFAULT_DATABASE_CONFIG["OPTIONS"] = {} else: DEFAULT_DATABASE_CONFIG["OPTIONS"] = {"sslmode": "require"} @@ -265,9 +265,9 @@ "guardian.backends.ObjectPermissionBackend", ) -SOCIAL_AUTH_LOGIN_REDIRECT_URL = get_string("MITOPEN_LOGIN_REDIRECT_URL", "/app") +SOCIAL_AUTH_LOGIN_REDIRECT_URL = get_string("MITOL_LOGIN_REDIRECT_URL", "/app") SOCIAL_AUTH_NEW_USER_LOGIN_REDIRECT_URL = get_string( - "MITOPEN_NEW_USER_LOGIN_URL", "/onboarding" + "MITOL_NEW_USER_LOGIN_URL", "/onboarding" ) SOCIAL_AUTH_LOGIN_ERROR_URL = "login" SOCIAL_AUTH_ALLOWED_REDIRECT_HOSTS = [ @@ -368,15 +368,15 @@ # Configure e-mail settings EMAIL_BACKEND = get_string( - "MITOPEN_EMAIL_BACKEND", "django.core.mail.backends.smtp.EmailBackend" + "MITOL_EMAIL_BACKEND", "django.core.mail.backends.smtp.EmailBackend" ) -EMAIL_HOST = get_string("MITOPEN_EMAIL_HOST", "localhost") -EMAIL_PORT = get_int("MITOPEN_EMAIL_PORT", 25) -EMAIL_HOST_USER = get_string("MITOPEN_EMAIL_USER", "") -EMAIL_HOST_PASSWORD = get_string("MITOPEN_EMAIL_PASSWORD", "") -EMAIL_USE_TLS = get_bool("MITOPEN_EMAIL_TLS", False) # noqa: FBT003 -EMAIL_SUPPORT = get_string("MITOPEN_SUPPORT_EMAIL", "support@example.com") -DEFAULT_FROM_EMAIL = get_string("MITOPEN_FROM_EMAIL", "webmaster@localhost") +EMAIL_HOST = get_string("MITOL_EMAIL_HOST", "localhost") +EMAIL_PORT = get_int("MITOL_EMAIL_PORT", 25) +EMAIL_HOST_USER = get_string("MITOL_EMAIL_USER", "") +EMAIL_HOST_PASSWORD = get_string("MITOL_EMAIL_PASSWORD", "") +EMAIL_USE_TLS = get_bool("MITOL_EMAIL_TLS", False) # noqa: FBT003 +EMAIL_SUPPORT = get_string("MITOL_SUPPORT_EMAIL", "support@example.com") +DEFAULT_FROM_EMAIL = get_string("MITOL_FROM_EMAIL", "webmaster@localhost") MAILGUN_SENDER_DOMAIN = get_string("MAILGUN_SENDER_DOMAIN", None) if not MAILGUN_SENDER_DOMAIN: @@ -396,10 +396,10 @@ } NOTIFICATION_EMAIL_BACKEND = get_string( - "MITOPEN_NOTIFICATION_EMAIL_BACKEND", "anymail.backends.test.EmailBackend" + "MITOL_NOTIFICATION_EMAIL_BACKEND", "anymail.backends.test.EmailBackend" ) # e-mail configurable admins -ADMIN_EMAIL = get_string("MITOPEN_ADMIN_EMAIL", "") +ADMIN_EMAIL = get_string("MITOL_ADMIN_EMAIL", "") ADMINS = (("Admins", ADMIN_EMAIL),) if ADMIN_EMAIL != "" else () # embed.ly configuration @@ -413,13 +413,13 @@ CKEDITOR_UPLOAD_URL = get_string("CKEDITOR_UPLOAD_URL", None) # Logging configuration -LOG_LEVEL = get_string("MITOPEN_LOG_LEVEL", "INFO") +LOG_LEVEL = get_string("MITOL_LOG_LEVEL", "INFO") DJANGO_LOG_LEVEL = get_string("DJANGO_LOG_LEVEL", "INFO") OS_LOG_LEVEL = get_string("OS_LOG_LEVEL", "INFO") # For logging to a remote syslog host -LOG_HOST = get_string("MITOPEN_LOG_HOST", "localhost") -LOG_HOST_PORT = get_int("MITOPEN_LOG_HOST_PORT", 514) +LOG_HOST = get_string("MITOL_LOG_HOST", "localhost") +LOG_HOST_PORT = get_int("MITOL_LOG_HOST_PORT", 514) HOSTNAME = platform.node().split(".")[0] @@ -491,18 +491,18 @@ MEDIA_ROOT = get_string("MEDIA_ROOT", "/var/media/") MEDIA_URL = "/media/" -MITOPEN_USE_S3 = get_bool("MITOPEN_USE_S3", False) # noqa: FBT003 +MITOL_USE_S3 = get_bool("MITOL_USE_S3", False) # noqa: FBT003 AWS_ACCESS_KEY_ID = get_string("AWS_ACCESS_KEY_ID", False) # noqa: FBT003 AWS_SECRET_ACCESS_KEY = get_string("AWS_SECRET_ACCESS_KEY", False) # noqa: FBT003 AWS_STORAGE_BUCKET_NAME = get_string("AWS_STORAGE_BUCKET_NAME", False) # noqa: FBT003 AWS_QUERYSTRING_AUTH = get_string("AWS_QUERYSTRING_AUTH", False) # noqa: FBT003 # Provide nice validation of the configuration -if MITOPEN_USE_S3 and ( +if MITOL_USE_S3 and ( not AWS_ACCESS_KEY_ID or not AWS_SECRET_ACCESS_KEY or not AWS_STORAGE_BUCKET_NAME ): msg = "You have enabled S3 support, but are missing one of AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, or AWS_STORAGE_BUCKET_NAME" # noqa: E501 raise ImproperlyConfigured(msg) -if MITOPEN_USE_S3: +if MITOL_USE_S3: DEFAULT_FILE_STORAGE = "storages.backends.s3boto3.S3Boto3Storage" IMAGEKIT_SPEC_CACHEFILE_NAMER = "imagekit.cachefiles.namers.source_name_dot_hash" @@ -562,37 +562,37 @@ INDEXING_ERROR_RETRIES = get_int("INDEXING_ERROR_RETRIES", 1) # JWT authentication settings -MITOPEN_JWT_SECRET = get_string( - "MITOPEN_JWT_SECRET", "terribly_unsafe_default_jwt_secret_key" +MITOL_JWT_SECRET = get_string( + "MITOL_JWT_SECRET", "terribly_unsafe_default_jwt_secret_key" ) -MITOPEN_COOKIE_NAME = get_string("MITOPEN_COOKIE_NAME", None) -if not MITOPEN_COOKIE_NAME: - msg = "MITOPEN_COOKIE_NAME is not set" +MITOL_COOKIE_NAME = get_string("MITOL_COOKIE_NAME", None) +if not MITOL_COOKIE_NAME: + msg = "MITOL_COOKIE_NAME is not set" raise ImproperlyConfigured(msg) -MITOPEN_COOKIE_DOMAIN = get_string("MITOPEN_COOKIE_DOMAIN", None) -if not MITOPEN_COOKIE_DOMAIN: - msg = "MITOPEN_COOKIE_DOMAIN is not set" +MITOL_COOKIE_DOMAIN = get_string("MITOL_COOKIE_DOMAIN", None) +if not MITOL_COOKIE_DOMAIN: + msg = "MITOL_COOKIE_DOMAIN is not set" raise ImproperlyConfigured(msg) -MITOPEN_UNSUBSCRIBE_TOKEN_MAX_AGE_SECONDS = get_int( - "MITOPEN_UNSUBSCRIBE_TOKEN_MAX_AGE_SECONDS", +MITOL_UNSUBSCRIBE_TOKEN_MAX_AGE_SECONDS = get_int( + "MITOL_UNSUBSCRIBE_TOKEN_MAX_AGE_SECONDS", 60 * 60 * 24 * 7, # 7 days ) JWT_AUTH = { - "JWT_SECRET_KEY": MITOPEN_JWT_SECRET, + "JWT_SECRET_KEY": MITOL_JWT_SECRET, "JWT_VERIFY": True, "JWT_VERIFY_EXPIRATION": True, "JWT_EXPIRATION_DELTA": datetime.timedelta(seconds=60 * 60), "JWT_ALLOW_REFRESH": True, "JWT_REFRESH_EXPIRATION_DELTA": datetime.timedelta(days=7), - "JWT_AUTH_COOKIE": MITOPEN_COOKIE_NAME, + "JWT_AUTH_COOKIE": MITOL_COOKIE_NAME, "JWT_AUTH_HEADER_PREFIX": "Bearer", } # Similar resources settings -MITOPEN_SIMILAR_RESOURCES_COUNT = get_int("MITOPEN_SIMILAR_RESOURCES_COUNT", 3) +MITOL_SIMILAR_RESOURCES_COUNT = get_int("MITOL_SIMILAR_RESOURCES_COUNT", 3) OPEN_RESOURCES_MIN_DOC_FREQ = get_int("OPEN_RESOURCES_MIN_DOC_FREQ", 1) OPEN_RESOURCES_MIN_TERM_FREQ = get_int("OPEN_RESOURCES_MIN_TERM_FREQ", 1) @@ -603,19 +603,19 @@ def get_all_config_keys(): return list(os.environ.keys()) -MITOPEN_FEATURES_PREFIX = get_string("MITOPEN_FEATURES_PREFIX", "FEATURE_") -MITOPEN_FEATURES_DEFAULT = get_bool("MITOPEN_FEATURES_DEFAULT", False) # noqa: FBT003 +MITOL_FEATURES_PREFIX = get_string("MITOL_FEATURES_PREFIX", "FEATURE_") +MITOL_FEATURES_DEFAULT = get_bool("MITOL_FEATURES_DEFAULT", False) # noqa: FBT003 FEATURES = { - key[len(MITOPEN_FEATURES_PREFIX) :]: get_any(key, None) + key[len(MITOL_FEATURES_PREFIX) :]: get_any(key, None) for key in get_all_config_keys() - if key.startswith(MITOPEN_FEATURES_PREFIX) + if key.startswith(MITOL_FEATURES_PREFIX) } MIDDLEWARE_FEATURE_FLAG_QS_PREFIX = get_string( "MIDDLEWARE_FEATURE_FLAG_QS_PREFIX", None ) MIDDLEWARE_FEATURE_FLAG_COOKIE_NAME = get_string( - "MIDDLEWARE_FEATURE_FLAG_COOKIE_NAME", "MITOPEN_FEATURE_FLAGS" + "MIDDLEWARE_FEATURE_FLAG_COOKIE_NAME", "MITOL_FEATURE_FLAGS" ) MIDDLEWARE_FEATURE_FLAG_COOKIE_MAX_AGE_SECONDS = get_int( "MIDDLEWARE_FEATURE_FLAG_COOKIE_MAX_AGE_SECONDS", 60 * 60 diff --git a/main/settings_pluggy.py b/main/settings_pluggy.py index 13f32233bc..f812b23c2a 100644 --- a/main/settings_pluggy.py +++ b/main/settings_pluggy.py @@ -1,10 +1,10 @@ from main.envs import get_string -MITOPEN_AUTHENTICATION_PLUGINS = get_string( - "MITOPEN_AUTHENTICATION_PLUGINS", +MITOL_AUTHENTICATION_PLUGINS = get_string( + "MITOL_AUTHENTICATION_PLUGINS", "learning_resources.plugins.FavoritesListPlugin,profiles.plugins.CreateProfilePlugin", ) -MITOPEN_LEARNING_RESOURCES_PLUGINS = get_string( - "MITOPEN_LEARNING_RESOURCES_PLUGINS", +MITOL_LEARNING_RESOURCES_PLUGINS = get_string( + "MITOL_LEARNING_RESOURCES_PLUGINS", "learning_resources_search.plugins.SearchIndexPlugin,channels.plugins.ChannelPlugin", ) diff --git a/main/settings_test.py b/main/settings_test.py index f5ab465352..66089d7b64 100644 --- a/main/settings_test.py +++ b/main/settings_test.py @@ -18,9 +18,9 @@ "OPENSEARCH_INDEX": "some_index", "MAILGUN_SENDER_DOMAIN": "mailgun.fake.domain", "MAILGUN_KEY": "fake_mailgun_key", - "MITOPEN_COOKIE_NAME": "cookie_monster", - "MITOPEN_COOKIE_DOMAIN": "od.fake.domain", - "MITOPEN_APP_BASE_URL": "http:localhost:8063/", + "MITOL_COOKIE_NAME": "cookie_monster", + "MITOL_COOKIE_DOMAIN": "od.fake.domain", + "MITOL_APP_BASE_URL": "http:localhost:8063/", } @@ -44,7 +44,7 @@ def test_s3_settings(self): # Unset, we don't do S3 with mock.patch.dict( "os.environ", - {**REQUIRED_SETTINGS, "MITOPEN_USE_S3": "False"}, + {**REQUIRED_SETTINGS, "MITOL_USE_S3": "False"}, clear=True, ): settings_vars = self.reload_settings() @@ -54,7 +54,7 @@ def test_s3_settings(self): ) with pytest.raises(ImproperlyConfigured): # noqa: SIM117 - with mock.patch.dict("os.environ", {"MITOPEN_USE_S3": "True"}, clear=True): + with mock.patch.dict("os.environ", {"MITOL_USE_S3": "True"}, clear=True): self.reload_settings() # Verify it all works with it enabled and configured 'properly' @@ -62,7 +62,7 @@ def test_s3_settings(self): "os.environ", { **REQUIRED_SETTINGS, - "MITOPEN_USE_S3": "True", + "MITOL_USE_S3": "True", "AWS_ACCESS_KEY_ID": "1", "AWS_SECRET_ACCESS_KEY": "2", "AWS_STORAGE_BUCKET_NAME": "3", @@ -80,7 +80,7 @@ def test_admin_settings(self): with mock.patch.dict( "os.environ", - {**REQUIRED_SETTINGS, "MITOPEN_ADMIN_EMAIL": ""}, + {**REQUIRED_SETTINGS, "MITOL_ADMIN_EMAIL": ""}, clear=True, ): settings_vars = self.reload_settings() @@ -89,7 +89,7 @@ def test_admin_settings(self): test_admin_email = "cuddle_bunnies@example.com" with mock.patch.dict( "os.environ", - {**REQUIRED_SETTINGS, "MITOPEN_ADMIN_EMAIL": test_admin_email}, + {**REQUIRED_SETTINGS, "MITOL_ADMIN_EMAIL": test_admin_email}, clear=True, ): settings_vars = self.reload_settings() @@ -113,7 +113,7 @@ def test_db_ssl_enable(self): # Check enabling the setting explicitly with mock.patch.dict( "os.environ", - {**REQUIRED_SETTINGS, "MITOPEN_DB_DISABLE_SSL": "True"}, + {**REQUIRED_SETTINGS, "MITOL_DB_DISABLE_SSL": "True"}, clear=True, ): settings_vars = self.reload_settings() @@ -122,7 +122,7 @@ def test_db_ssl_enable(self): # Disable it with mock.patch.dict( "os.environ", - {**REQUIRED_SETTINGS, "MITOPEN_DB_DISABLE_SSL": "False"}, + {**REQUIRED_SETTINGS, "MITOL_DB_DISABLE_SSL": "False"}, clear=True, ): settings_vars = self.reload_settings() @@ -174,10 +174,10 @@ def test_server_side_cursors_disabled(self): ) def test_server_side_cursors_enabled(self): - """DISABLE_SERVER_SIDE_CURSORS should be false if MITOPEN_DB_DISABLE_SS_CURSORS is false""" + """DISABLE_SERVER_SIDE_CURSORS should be false if MITOL_DB_DISABLE_SS_CURSORS is false""" with mock.patch.dict( "os.environ", - {**REQUIRED_SETTINGS, "MITOPEN_DB_DISABLE_SS_CURSORS": "False"}, + {**REQUIRED_SETTINGS, "MITOL_DB_DISABLE_SS_CURSORS": "False"}, ): settings_vars = self.reload_settings() assert ( diff --git a/manage.py b/manage.py index db5ad8bc5c..f817136f12 100755 --- a/manage.py +++ b/manage.py @@ -6,9 +6,24 @@ import os import sys + +def set_env_vars_from_legacy_prefix(): + """ + Walk the environment variables and set the new MITOL_ prefixed ones + from legacy MIT_OPEN_ prefixed ones + """ + for old_key in os.environ: + if old_key.startswith("MIT_OPEN_"): + new_key = old_key.replace("MIT_OPEN_", "MITOL_") + + os.environ[new_key] = os.environ[old_key] + + if __name__ == "__main__": os.environ.setdefault("DJANGO_SETTINGS_MODULE", "main.settings") + set_env_vars_from_legacy_prefix() + from django.core.management import execute_from_command_line execute_from_command_line(sys.argv) diff --git a/package.json b/package.json index 4a69c30e36..4781373aae 100644 --- a/package.json +++ b/package.json @@ -15,8 +15,8 @@ "build": "yarn workspace mit-open run build", "watch": "yarn workspace mit-open run watch", "style-lint": "yarn workspace frontends run style-lint", - "test": "MITOPEN_API_BASE_URL=https://api.test.learn.mit.edu yarn workspace frontends global:test", - "test-watch": "MITOPEN_API_BASE_URL=https://api.test.learn.mit.edu yarn workspace frontends test-watch", + "test": "MITOL_API_BASE_URL=https://api.test.learn.mit.edu yarn workspace frontends global:test", + "test-watch": "MITOL_API_BASE_URL=https://api.test.learn.mit.edu yarn workspace frontends test-watch", "storybook": "yarn workspace frontends storybook", "lint-check": "yarn workspace frontends run lint-check", "typecheck": "yarn workspace frontends run typecheck" diff --git a/pytest.ini b/pytest.ini index 97e463f158..44c42e250e 100644 --- a/pytest.ini +++ b/pytest.ini @@ -10,11 +10,11 @@ env = DEBUG=False OCW_WEBHOOK_KEY=fake_key OPENSEARCH_INDEX=testindex - MITOPEN_COOKIE_DOMAIN=localhost - MITOPEN_COOKIE_NAME=cookie_monster - MITOPEN_FEATURES_DEFAULT=False - MITOPEN_SECURE_SSL_REDIRECT=False - MITOPEN_USE_S3=False + MITOL_COOKIE_DOMAIN=localhost + MITOL_COOKIE_NAME=cookie_monster + MITOL_FEATURES_DEFAULT=False + MITOL_SECURE_SSL_REDIRECT=False + MITOL_USE_S3=False SENTRY_DSN= TIKA_CLIENT_ONLY=True POSTHOG_PERSONAL_API_KEY=fake_key # pragma: allowlist secret