feat!: upgrade Django version to 4.2 (LTS)

This reverts commit 23659d5ba8.
This commit is contained in:
Muhammad Soban Javed
2024-02-02 14:44:11 +05:00
committed by Muhammad Soban Javed
parent a9bd61d015
commit e40a01c7cc
13 changed files with 58 additions and 41 deletions

View File

@@ -16,16 +16,11 @@ jobs:
os: [ ubuntu-20.04 ] os: [ ubuntu-20.04 ]
python-version: [ 3.8 ] python-version: [ 3.8 ]
# 'pinned' is used to install the latest patch version of Django # 'pinned' is used to install the latest patch version of Django
# within the global constraint i.e. Django==3.2.21 in current case # within the global constraint i.e. Django==4.2.8 in current case
# because we have global constraint of Django<4.2 # because we have global constraint of Django<4.2
django-version: ["pinned", "4.2"] django-version: ["pinned"]
mongo-version: ["4"] mongo-version: ["4"]
mysql-version: ["5.7", "8"] mysql-version: ["8"]
# excluding mysql5.7 with Django 4.2 since Django 4.2 has
# dropped support for MySQL<8
exclude:
- django-version: "4.2"
mysql-version: "5.7"
services: services:
mongo: mongo:
image: mongo:${{ matrix.mongo-version }} image: mongo:${{ matrix.mongo-version }}

View File

@@ -17,7 +17,6 @@ jobs:
- "3.8" - "3.8"
django-version: django-version:
- "pinned" - "pinned"
- "4.2"
# When updating the shards, remember to make the same changes in # When updating the shards, remember to make the same changes in
# .github/workflows/unit-tests-gh-hosted.yml # .github/workflows/unit-tests-gh-hosted.yml
shard_name: shard_name:

View File

@@ -157,6 +157,8 @@ compile-requirements: pre-requirements $(COMMON_CONSTRAINTS_TXT) ## Re-compile *
@# time someone tries to use the outputs. @# time someone tries to use the outputs.
sed '/^django-simple-history==/d' requirements/common_constraints.txt > requirements/common_constraints.tmp sed '/^django-simple-history==/d' requirements/common_constraints.txt > requirements/common_constraints.tmp
mv requirements/common_constraints.tmp requirements/common_constraints.txt mv requirements/common_constraints.tmp requirements/common_constraints.txt
sed 's/Django<4.0//g' requirements/common_constraints.txt > requirements/common_constraints.tmp
mv requirements/common_constraints.tmp requirements/common_constraints.txt
pip-compile -v --allow-unsafe ${COMPILE_OPTS} -o requirements/pip.txt requirements/pip.in pip-compile -v --allow-unsafe ${COMPILE_OPTS} -o requirements/pip.txt requirements/pip.in
pip install -r requirements/pip.txt pip install -r requirements/pip.txt

View File

@@ -1105,8 +1105,8 @@ DATABASES = {
} }
DEFAULT_AUTO_FIELD = 'django.db.models.AutoField' DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'
# This will be overridden through CMS config DEFAULT_HASHING_ALGORITHM = 'sha256'
DEFAULT_HASHING_ALGORITHM = 'sha1'
#################### Python sandbox ############################################ #################### Python sandbox ############################################
CODE_JAIL = { CODE_JAIL = {

View File

@@ -1768,8 +1768,8 @@ DATABASES = {
DEFAULT_AUTO_FIELD = 'django.db.models.AutoField' DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'
# This will be overridden through LMS config DEFAULT_HASHING_ALGORITHM = 'sha256'
DEFAULT_HASHING_ALGORITHM = 'sha1'
#################### Python sandbox ############################################ #################### Python sandbox ############################################
CODE_JAIL = { CODE_JAIL = {

View File

@@ -236,7 +236,7 @@ class TestSafeCookieData(TestSafeSessionsLogMixin, TestCase):
"|HvGnjXf1b3jU" "|HvGnjXf1b3jU"
"|ImExZWZiNzVlZGFmM2FkZWZmYjM4YjI0ZmZkOWU4MzExODU0MTk4NmVlNGRiYzBlODdhYWUzOGM5MzVlNzk4NjUi" "|ImExZWZiNzVlZGFmM2FkZWZmYjM4YjI0ZmZkOWU4MzExODU0MTk4NmVlNGRiYzBlODdhYWUzOGM5MzVlNzk4NjUi"
":1m6Hve" ":1m6Hve"
":OMhY2FL2pudJjSSXChtI-zR8QVA" ":Pra4iochviPvKUoIV33gdVZFDgG-cMDlIYfl8iFIMaY"
) )
@pytest.mark.skipif(django.VERSION[0] < 4, reason="For django42 default algorithm is sha256. No need for django32.") @pytest.mark.skipif(django.VERSION[0] < 4, reason="For django42 default algorithm is sha256. No need for django32.")

View File

@@ -192,33 +192,41 @@ class ThemeManifestFilesMixin(ManifestFilesMixin):
This requires figuring out which files the matched URL resolves This requires figuring out which files the matched URL resolves
to and calling the url() method of the storage. to and calling the url() method of the storage.
""" """
matched, url = matchobj.groups() matches = matchobj.groupdict()
matched = matches["matched"]
url = matches["url"]
# Ignore absolute/protocol-relative and data-uri URLs. # Ignore absolute/protocol-relative and data-uri URLs.
if re.match(r'^[a-z]+:', url): if re.match(r"^[a-z]+:", url):
return matched return matched
# Ignore absolute URLs that don't point to a static file (dynamic # Ignore absolute URLs that don't point to a static file (dynamic
# CSS / JS?). Note that STATIC_URL cannot be empty. # CSS / JS?). Note that STATIC_URL cannot be empty.
if url.startswith('/') and not url.startswith(settings.STATIC_URL): if url.startswith("/") and not url.startswith(settings.STATIC_URL):
return matched return matched
# Strip off the fragment so a path-like fragment won't interfere. # Strip off the fragment so a path-like fragment won't interfere.
url_path, fragment = urldefrag(url) url_path, fragment = urldefrag(url)
if url_path.startswith('/'): # Ignore URLs without a path
if not url_path:
return matched
if url_path.startswith("/"):
# Otherwise the condition above would have returned prematurely. # Otherwise the condition above would have returned prematurely.
assert url_path.startswith(settings.STATIC_URL) assert url_path.startswith(settings.STATIC_URL)
target_name = url_path[len(settings.STATIC_URL):] target_name = url_path[len(settings.STATIC_URL):]
else: else:
# We're using the posixpath module to mix paths and URLs conveniently. # We're using the posixpath module to mix paths and URLs conveniently.
source_name = name if os.sep == '/' else name.replace(os.sep, '/') source_name = name if os.sep == "/" else name.replace(os.sep, "/")
target_name = posixpath.join(posixpath.dirname(source_name), url_path) target_name = posixpath.join(posixpath.dirname(source_name), url_path)
# Determine the hashed name of the target file with the storage backend. # Determine the hashed name of the target file with the storage backend.
hashed_url = self._url( hashed_url = self._url(
self._stored_name, unquote(target_name), self._stored_name,
force=True, hashed_files=hashed_files, unquote(target_name),
force=True,
hashed_files=hashed_files,
) )
# NOTE: # NOTE:
@@ -228,15 +236,19 @@ class ThemeManifestFilesMixin(ManifestFilesMixin):
# The line is commented and not removed to make future django upgrade easier and show exactly what is # The line is commented and not removed to make future django upgrade easier and show exactly what is
# changed in this method override # changed in this method override
# #
#transformed_url = '/'.join(url_path.split('/')[:-1] + hashed_url.split('/')[-1:]) # transformed_url = "/".join(
# url_path.split("/")[:-1] + hashed_url.split("/")[-1:]
# )
transformed_url = hashed_url # This line was added. transformed_url = hashed_url # This line was added.
# Restore the fragment that was stripped off earlier. # Restore the fragment that was stripped off earlier.
if fragment: if fragment:
transformed_url += ('?#' if '?#' in url else '#') + fragment transformed_url += ("?#" if "?#" in url else "#") + fragment
# Return the hashed version to the file # Return the hashed version to the file
return template % unquote(transformed_url) matches["url"] = unquote(transformed_url)
return template % matches
return converter return converter

View File

@@ -17,7 +17,7 @@
# using LTS django version # using LTS django version
Django<4.0
# elasticsearch>=7.14.0 includes breaking changes in it which caused issues in discovery upgrade process. # elasticsearch>=7.14.0 includes breaking changes in it which caused issues in discovery upgrade process.
# elastic search changelog: https://www.elastic.co/guide/en/enterprise-search/master/release-notes-7.14.0.html # elastic search changelog: https://www.elastic.co/guide/en/enterprise-search/master/release-notes-7.14.0.html

View File

@@ -25,10 +25,15 @@ click>=8.0,<9.0
# for them. # for them.
edx-enterprise==4.11.6 edx-enterprise==4.11.6
# Stay on LTS version, remove once this is added to common constraint
Django<5.0
# django-oauth-toolkit version >=2.0.0 has breaking changes. More details # django-oauth-toolkit version >=2.0.0 has breaking changes. More details
# mentioned on this issue https://github.com/openedx/edx-platform/issues/32884 # mentioned on this issue https://github.com/openedx/edx-platform/issues/32884
django-oauth-toolkit==1.7.1 django-oauth-toolkit==1.7.1
# incremental upgrade
django-simple-history==3.4.0
# constrained in opaque_keys. migration guide here: https://pymongo.readthedocs.io/en/4.0/migrate-to-pymongo4.html # constrained in opaque_keys. migration guide here: https://pymongo.readthedocs.io/en/4.0/migrate-to-pymongo4.html
# Major upgrade will be done in separate ticket. # Major upgrade will be done in separate ticket.

View File

@@ -56,6 +56,7 @@ backoff==1.10.0
backports-zoneinfo[tzdata]==0.2.1 backports-zoneinfo[tzdata]==0.2.1
# via # via
# celery # celery
# django
# icalendar # icalendar
# kombu # kombu
beautifulsoup4==4.12.3 beautifulsoup4==4.12.3
@@ -173,9 +174,9 @@ defusedxml==0.7.1
# social-auth-core # social-auth-core
deprecated==1.2.14 deprecated==1.2.14
# via jwcrypto # via jwcrypto
django==3.2.23 django==4.2.9
# via # via
# -c requirements/edx/../common_constraints.txt # -c requirements/edx/../constraints.txt
# -r requirements/edx/kernel.in # -r requirements/edx/kernel.in
# django-appconf # django-appconf
# django-celery-results # django-celery-results
@@ -338,6 +339,7 @@ django-ses==3.5.2
# via -r requirements/edx/bundled.in # via -r requirements/edx/bundled.in
django-simple-history==3.4.0 django-simple-history==3.4.0
# via # via
# -c requirements/edx/../constraints.txt
# -r requirements/edx/kernel.in # -r requirements/edx/kernel.in
# edx-enterprise # edx-enterprise
# edx-name-affirmation # edx-name-affirmation
@@ -431,7 +433,7 @@ edx-ccx-keys==1.2.1
# via # via
# -r requirements/edx/kernel.in # -r requirements/edx/kernel.in
# lti-consumer-xblock # lti-consumer-xblock
edx-celeryutils==1.2.3 edx-celeryutils==1.2.5
# via # via
# -r requirements/edx/kernel.in # -r requirements/edx/kernel.in
# edx-name-affirmation # edx-name-affirmation
@@ -940,7 +942,6 @@ pytz==2023.4
# via # via
# -r requirements/edx/kernel.in # -r requirements/edx/kernel.in
# babel # babel
# django
# django-ses # django-ses
# djangorestframework # djangorestframework
# drf-yasg # drf-yasg

View File

@@ -116,6 +116,7 @@ backports-zoneinfo[tzdata]==0.2.1
# -r requirements/edx/testing.txt # -r requirements/edx/testing.txt
# backports-zoneinfo # backports-zoneinfo
# celery # celery
# django
# icalendar # icalendar
# kombu # kombu
beautifulsoup4==4.12.3 beautifulsoup4==4.12.3
@@ -341,9 +342,9 @@ distlib==0.3.8
# via # via
# -r requirements/edx/testing.txt # -r requirements/edx/testing.txt
# virtualenv # virtualenv
django==3.2.23 django==4.2.9
# via # via
# -c requirements/edx/../common_constraints.txt # -c requirements/edx/../constraints.txt
# -r requirements/edx/doc.txt # -r requirements/edx/doc.txt
# -r requirements/edx/testing.txt # -r requirements/edx/testing.txt
# django-appconf # django-appconf
@@ -559,6 +560,7 @@ django-ses==3.5.2
# -r requirements/edx/testing.txt # -r requirements/edx/testing.txt
django-simple-history==3.4.0 django-simple-history==3.4.0
# via # via
# -c requirements/edx/../constraints.txt
# -r requirements/edx/doc.txt # -r requirements/edx/doc.txt
# -r requirements/edx/testing.txt # -r requirements/edx/testing.txt
# edx-enterprise # edx-enterprise
@@ -701,7 +703,7 @@ edx-ccx-keys==1.2.1
# -r requirements/edx/doc.txt # -r requirements/edx/doc.txt
# -r requirements/edx/testing.txt # -r requirements/edx/testing.txt
# lti-consumer-xblock # lti-consumer-xblock
edx-celeryutils==1.2.3 edx-celeryutils==1.2.5
# via # via
# -r requirements/edx/doc.txt # -r requirements/edx/doc.txt
# -r requirements/edx/testing.txt # -r requirements/edx/testing.txt
@@ -1670,7 +1672,6 @@ pytz==2023.4
# -r requirements/edx/doc.txt # -r requirements/edx/doc.txt
# -r requirements/edx/testing.txt # -r requirements/edx/testing.txt
# babel # babel
# django
# django-ses # django-ses
# djangorestframework # djangorestframework
# drf-yasg # drf-yasg

View File

@@ -79,6 +79,7 @@ backports-zoneinfo[tzdata]==0.2.1
# -r requirements/edx/base.txt # -r requirements/edx/base.txt
# backports-zoneinfo # backports-zoneinfo
# celery # celery
# django
# icalendar # icalendar
# kombu # kombu
beautifulsoup4==4.12.3 beautifulsoup4==4.12.3
@@ -223,9 +224,9 @@ deprecated==1.2.14
# via # via
# -r requirements/edx/base.txt # -r requirements/edx/base.txt
# jwcrypto # jwcrypto
django==3.2.23 django==4.2.9
# via # via
# -c requirements/edx/../common_constraints.txt # -c requirements/edx/../constraints.txt
# -r requirements/edx/base.txt # -r requirements/edx/base.txt
# django-appconf # django-appconf
# django-celery-results # django-celery-results
@@ -404,6 +405,7 @@ django-ses==3.5.2
# via -r requirements/edx/base.txt # via -r requirements/edx/base.txt
django-simple-history==3.4.0 django-simple-history==3.4.0
# via # via
# -c requirements/edx/../constraints.txt
# -r requirements/edx/base.txt # -r requirements/edx/base.txt
# edx-enterprise # edx-enterprise
# edx-name-affirmation # edx-name-affirmation
@@ -509,7 +511,7 @@ edx-ccx-keys==1.2.1
# via # via
# -r requirements/edx/base.txt # -r requirements/edx/base.txt
# lti-consumer-xblock # lti-consumer-xblock
edx-celeryutils==1.2.3 edx-celeryutils==1.2.5
# via # via
# -r requirements/edx/base.txt # -r requirements/edx/base.txt
# edx-name-affirmation # edx-name-affirmation
@@ -1123,7 +1125,6 @@ pytz==2023.4
# via # via
# -r requirements/edx/base.txt # -r requirements/edx/base.txt
# babel # babel
# django
# django-ses # django-ses
# djangorestframework # djangorestframework
# drf-yasg # drf-yasg

View File

@@ -81,6 +81,7 @@ backports-zoneinfo[tzdata]==0.2.1
# -r requirements/edx/base.txt # -r requirements/edx/base.txt
# backports-zoneinfo # backports-zoneinfo
# celery # celery
# django
# icalendar # icalendar
# kombu # kombu
beautifulsoup4==4.12.3 beautifulsoup4==4.12.3
@@ -254,9 +255,9 @@ dill==0.3.8
# via pylint # via pylint
distlib==0.3.8 distlib==0.3.8
# via virtualenv # via virtualenv
django==3.2.23 django==4.2.9
# via # via
# -c requirements/edx/../common_constraints.txt # -c requirements/edx/../constraints.txt
# -r requirements/edx/base.txt # -r requirements/edx/base.txt
# django-appconf # django-appconf
# django-celery-results # django-celery-results
@@ -435,6 +436,7 @@ django-ses==3.5.2
# via -r requirements/edx/base.txt # via -r requirements/edx/base.txt
django-simple-history==3.4.0 django-simple-history==3.4.0
# via # via
# -c requirements/edx/../constraints.txt
# -r requirements/edx/base.txt # -r requirements/edx/base.txt
# edx-enterprise # edx-enterprise
# edx-name-affirmation # edx-name-affirmation
@@ -535,7 +537,7 @@ edx-ccx-keys==1.2.1
# via # via
# -r requirements/edx/base.txt # -r requirements/edx/base.txt
# lti-consumer-xblock # lti-consumer-xblock
edx-celeryutils==1.2.3 edx-celeryutils==1.2.5
# via # via
# -r requirements/edx/base.txt # -r requirements/edx/base.txt
# edx-name-affirmation # edx-name-affirmation
@@ -1251,7 +1253,6 @@ pytz==2023.4
# via # via
# -r requirements/edx/base.txt # -r requirements/edx/base.txt
# babel # babel
# django
# django-ses # django-ses
# djangorestframework # djangorestframework
# drf-yasg # drf-yasg