From 50ac3f964aefdfee42f73397d79baa50e642c409 Mon Sep 17 00:00:00 2001 From: Jonathan Reveille Date: Tue, 7 May 2024 17:17:18 +0200 Subject: [PATCH] =?UTF-8?q?=E2=AC=86=EF=B8=8F(backend)=20pin=20django=20to?= =?UTF-8?q?=20a=20version=20<=205?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since Django 4.2, we have dropped the support of mysql < 8. We have dropped the job on circleci for `test-back-mysql-5`. We have updated in settings `STORAGES` configuration for staticfiles and default file storage declaration. --- .circleci/config.yml | 101 ------------------ CHANGELOG.md | 3 + UPGRADE.md | 30 +++--- .../backend/{{cookiecutter.site}}/settings.py | 14 ++- pyproject.toml | 2 +- sandbox/settings.py | 8 +- .../courses/test_admin_form_course_run.py | 2 +- tests/apps/search/test_signals.py | 2 +- 8 files changed, 38 insertions(+), 124 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index ef4ea3c0ca..1f51875eae 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -246,99 +246,6 @@ jobs: name: upload files to crowdin command: crowdin upload sources -c crowdin/config.yml - test-back-mysql-5: - docker: - - image: cimg/python:3.10 - auth: - username: $DOCKER_USER - password: $DOCKER_PASS - environment: - DJANGO_SETTINGS_MODULE: settings - DJANGO_CONFIGURATION: Test - DJANGO_SECRET_KEY: ThisIsAnExampleKeyForTestPurposeOnly - PYTHONPATH: /home/circleci/fun/sandbox - RICHIE_ES_HOST: localhost - DB_ENGINE: django.db.backends.mysql - # The DB_HOST should match the host name and cannot be set from here - # where it will be escaped. See the test command instead: - # DB_HOST=${HOSTNAME} - DB_HOST: - DB_NAME: richie - DB_USER: fun - DB_PASSWORD: pass - DB_PORT: 3306 - # services - - image: cimg/mysql:5.7 - auth: - username: $DOCKER_USER - password: $DOCKER_PASS - environment: - MYSQL_ROOT_PASSWORD: - MYSQL_DATABASE: test_richie - MYSQL_USER: fun - MYSQL_PASSWORD: pass - command: mysqld --character-set-server=utf8 --collation-server=utf8_general_ci - - image: elasticsearch:7.14.0 - auth: - username: $DOCKER_USER - password: $DOCKER_PASS - environment: - discovery.type: single-node - - image: docker.io/bitnami/redis:6.0-debian-10 - auth: - username: $DOCKER_USER - password: $DOCKER_PASS - name: redis-primary - environment: - ALLOW_EMPTY_PASSWORD: yes - REDIS_REPLICATION_MODE: master - - image: docker.io/bitnami/redis-sentinel:6.0-debian-10 - auth: - username: $DOCKER_USER - password: $DOCKER_PASS - name: redis-sentinel - environment: - REDIS_MASTER_HOST: redis-primary - working_directory: ~/fun - steps: - - checkout - - restore_cache: - keys: - - v2-back-dependencies-{{ .Revision }} - # Attach the frontend production build - - attach_workspace: - at: ~/fun - - *install-libcairo2-dev - # While running tests, we need to make the /data directory writable for - # the circleci user - - run: - name: Create writable /data - command: | - sudo mkdir /data && \ - sudo chown circleci:circleci /data - # Run back-end (Django) test suite - # - # Nota bene: - # - # 1. to run the django test suite, we need to ensure that both MySQL and - # ElasticSearch services are up and ready. To achieve this, we wrap the - # pytest command execution with dockerize, a tiny tool installed in the - # CircleCI image. In our case, dockerize will wait up to one minute - # that both the database and elastisearch containers opened their - # expected tcp port (3306 and 9200 resp.). - # 2. We should avoid using localhost for the DB_HOST with MySQL as the - # client will try to use a local socket (_e.g._ - # `/var/run/mysqld/mysqld.sock`) instead of the database host and port - # ¯\_(ツ)_/¯. - - run: - name: Run tests - command: | - DB_HOST=${HOSTNAME} dockerize \ - -wait tcp://${HOSTNAME}:3306 \ - -wait tcp://${HOSTNAME}:9200 \ - -timeout 60s \ - ~/.local/bin/pytest - test-back-mysql-8: docker: - image: cimg/python:3.10 @@ -1082,13 +989,6 @@ workflows: filters: tags: only: /.*/ - - test-back-mysql-5: - requires: - - build-back - - build-front-production - filters: - tags: - only: /.*/ - test-back-mysql-8: requires: - build-back @@ -1139,7 +1039,6 @@ workflows: - package-back: requires: - test-front - - test-back-mysql-5 - test-back-mysql-8 - test-back-postgresql - test-back-postgresql-es6 diff --git a/CHANGELOG.md b/CHANGELOG.md index 2860ca59db..5d31ec40bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,9 @@ Versioning](https://semver.org/spec/v2.0.0.html). ## Changed +- Update configuration setting `STATICFILES_STORAGE` and + `DEFAULT_FILE_STORAGE` with `STORAGES` dictionary configuration +- Pin Django version < 5 and dropped support for mysql version < 5 - Upgrade to Django 4.1 version - Upgrade to Django 4.0 version and postgres to version 12 in docker compose file diff --git a/UPGRADE.md b/UPGRADE.md index 3df22a561f..10029f549a 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -16,6 +16,8 @@ $ make migrate ## Unreleased +- Dropped support for postgres version < 12 +- Dropped support for MySQL version < 8 - Add new `dashboard-splitted-card` theme scheme ``` dashboard-splitted-card: ( @@ -45,7 +47,7 @@ $ make migrate `scss/trumps/_bootstrap.scss` file. You have to import it in your `_main.scss` file. ```scss // ... - + // Import bootstrap reset @import 'richie-education/scss/trumps/bootstrap'; ``` @@ -67,7 +69,7 @@ $ make migrate the urls module of your app. ```python from richie.apps.courses.urls import redirects_urlpatterns as courses_redirects_urlpatterns - + urlpatterns += [ re_path(r"^redirects/", include([*courses_redirects_urlpatterns])), ] @@ -81,7 +83,7 @@ $ make migrate @import '@openfun/cunningham-react/dist/style'; @import 'richie-education/scss/vendors/cunningham-tokens'; @import 'richie-education/scss/vendors/css/cunningham-tokens'; - + // Override default Richie settings variables @import 'richie-education/scss/colors/palette'; // ... @@ -89,12 +91,12 @@ $ make migrate `yarn build-theme` command generates tokens files `scss/vendors/cunningham-tokens.scss` and `scss/vendors/css/cunningham-tokens.css`. `$palette` variable is now deprecated and will be removed in the next major release. Currently this is only an alias to the - `map.get($theme, colors)` ($theme is a sass variable exported by `cunninghtam-tokens.scss`). -- Components `CourseGlimpse` and `CourseGlimpseList` has been moved from `js/widgets/Search` folder to + `map.get($theme, colors)` ($theme is a sass variable exported by `cunninghtam-tokens.scss`). +- Components `CourseGlimpse` and `CourseGlimpseList` has been moved from `js/widgets/Search` folder to `js/components` folder. Update your overrides.json and path in your custom scss files accordingly. -- `js/utils/test/factories.ts` have been split into multiple files: joanie.ts, richie.ts and +- `js/utils/test/factories.ts` have been split into multiple files: joanie.ts, richie.ts and reactQuery.ts. Update your import accordingly. - + ## 2.20.1 to 2.21.0 - Frontend folder architecture has been totally reworked. If you have overridden @@ -141,7 +143,7 @@ $ make migrate ## 2.18.x to 2.19.x -- In `_theme.scss`, `course-detail` scheme now accepts two new optional properties to style +- In `_theme.scss`, `course-detail` scheme now accepts two new optional properties to style the course run CTA and feedback color in the course detail subheader: - `subheader-run-cta` - `subheader-run-feedback-color` @@ -179,7 +181,7 @@ $ make migrate "JS_COURSE_REGEX": r"^.*/api/v1.0/(course-runs|products)/([^/]*)/?$", # A list of course run properties to not update "COURSE_RUN_SYNC_NO_UPDATE_FIELDS": [], - # The synchronization mode ("manual", "sync_to_public" or "sync_to_draft") + # The synchronization mode ("manual", "sync_to_public" or "sync_to_draft") "DEFAULT_COURSE_RUN_SYNC_MODE": "sync_to_public", } ``` @@ -224,7 +226,7 @@ $ make migrate - `_main.scss` ```diff + @import 'richie-education/scss/tools/utils'; - + + @import 'richie-education/js/components/AddressesManagement/styles'; + @import 'richie-education/js/components/CourseProductCertificateItem/styles'; + @import 'richie-education/js/components/CourseProductCourseRuns/styles'; @@ -239,7 +241,7 @@ $ make migrate ... + @import 'richie-education/scss/components/templates/richie/multiple-columns'; ``` - + - Only if you have overridden `_palette.scss`: ```diff $palette = { @@ -335,7 +337,7 @@ $ make migrate ## 2.11.x to 2.12.x -- If you overrode `course-detail` theme within `theme.scss`, you have to add these four +- If you overrode `course-detail` theme within `theme.scss`, you have to add these four new properties ```scss view-more-runs-color: r-color('firebrick6'), @@ -348,8 +350,8 @@ $ make migrate - If you overrode `richie/base.html`, the `branding_footer` template block has been renamed to `body_footer_brand` and the link was integrated in the block so it can be customized. -- The file `_colors.scss` has been divided into `_palette.scss` for the palette, - `_gradients.scss`, `_schemes.scss` and `_theme.scss`. Those files are now located in a +- The file `_colors.scss` has been divided into `_palette.scss` for the palette, + `_gradients.scss`, `_schemes.scss` and `_theme.scss`. Those files are now located in a dedicated folder `colors`. ## 2.9.x to 2.10.x diff --git a/cookiecutter/{{cookiecutter.organization}}-richie-site-factory/template/{{cookiecutter.site}}/src/backend/{{cookiecutter.site}}/settings.py b/cookiecutter/{{cookiecutter.organization}}-richie-site-factory/template/{{cookiecutter.site}}/src/backend/{{cookiecutter.site}}/settings.py index 66fa61891e..ad4c7755bc 100644 --- a/cookiecutter/{{cookiecutter.organization}}-richie-site-factory/template/{{cookiecutter.site}}/src/backend/{{cookiecutter.site}}/settings.py +++ b/cookiecutter/{{cookiecutter.organization}}-richie-site-factory/template/{{cookiecutter.site}}/src/backend/{{cookiecutter.site}}/settings.py @@ -196,7 +196,11 @@ class Base(StyleguideMixin, DRFMixin, RichieCoursesConfigurationMixin, Configura # For static files, we want to use a backend that includes a hash in # the filename, that is calculated from the file content, so that browsers always # get the updated version of each file. - STATICFILES_STORAGE = values.Value("base.storage.CDNManifestStaticFilesStorage") + STORAGES = { + "staticfiles": { + "BACKEND": values.Value("base.storage.CDNManifestStaticFilesStorage") + } + } AUTHENTICATION_BACKENDS = ("django.contrib.auth.backends.ModelBackend",) @@ -719,7 +723,11 @@ class Development(Base): class Test(Base): """Test environment settings""" - STATICFILES_STORAGE = "django.contrib.staticfiles.storage.StaticFilesStorage" + STORAGES = { + "staticfile": { + "BACKEND": "django.contrib.staticfiles.storage.StaticFilesStorage" + } + } class ContinuousIntegration(Test): @@ -746,7 +754,7 @@ class Production(Base): SECURE_CONTENT_TYPE_NOSNIFF = True SESSION_COOKIE_SECURE = True - DEFAULT_FILE_STORAGE = "base.storage.MediaStorage" + STORAGES = {"default": {"BACKEND": "base.storage.MediaStorage"}} AWS_DEFAULT_ACL = None AWS_LOCATION = "media" diff --git a/pyproject.toml b/pyproject.toml index d547b54d8f..01ee15226d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -25,7 +25,7 @@ classifiers = [ ] dependencies = [ "arrow", - "Django==4.1", + "Django<5", "djangocms-file", "djangocms-googlemap", "djangocms-link", diff --git a/sandbox/settings.py b/sandbox/settings.py index 5d1cc1d788..2f5dc9cfeb 100644 --- a/sandbox/settings.py +++ b/sandbox/settings.py @@ -713,9 +713,11 @@ class Production(Base): # For static files in production, we want to use a backend that includes a hash in # the filename, that is calculated from the file content, so that browsers always # get the updated version of each file. - STATICFILES_STORAGE = ( - "django.contrib.staticfiles.storage.ManifestStaticFilesStorage" - ) + STORAGES = { + "staticfiles": { + "BACKEND": "django.contrib.staticfiles.storage.StaticFilesStorage" + } + } # For more details about CMS_CACHE_DURATION, see : # http://docs.django-cms.org/en/latest/reference/configuration.html#cms-cache-durations diff --git a/tests/apps/courses/test_admin_form_course_run.py b/tests/apps/courses/test_admin_form_course_run.py index 975d0183d4..d927c4e34b 100644 --- a/tests/apps/courses/test_admin_form_course_run.py +++ b/tests/apps/courses/test_admin_form_course_run.py @@ -255,7 +255,7 @@ def test_admin_form_course_run_choices_languages(self): CourseRunAdminForm.request = request form = CourseRunAdminForm() - self.assertEqual(form.fields["languages"].choices[32][1], "German") + self.assertEqual(form.fields["languages"].choices[33][1], "German") with translation.override("fr"): form = CourseRunAdminForm() diff --git a/tests/apps/search/test_signals.py b/tests/apps/search/test_signals.py index 4ef3eb2fbc..812e07e053 100644 --- a/tests/apps/search/test_signals.py +++ b/tests/apps/search/test_signals.py @@ -37,7 +37,7 @@ def run_commit_hooks(): Run commit hooks as if the database transaction had been successful. """ while connection.run_on_commit: - _sids, func = connection.run_on_commit.pop(0) + _sids, func, _published_value = connection.run_on_commit.pop(0) func() def test_signals_courses_publish(self, mock_bulk, *_):