Skip to content

Commit

Permalink
Revert "feat!: upgrade Django version to 4.2 (LTS) (#34162)" (#34165)
Browse files Browse the repository at this point in the history
This reverts commit 1fc2e8a.
  • Loading branch information
UsamaSadiq authored Feb 1, 2024
1 parent 6b0c5c6 commit 23659d5
Show file tree
Hide file tree
Showing 13 changed files with 41 additions and 58 deletions.
11 changes: 8 additions & 3 deletions .github/workflows/migrations-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,16 @@ jobs:
os: [ ubuntu-20.04 ]
python-version: [ 3.8 ]
# 'pinned' is used to install the latest patch version of Django
# within the global constraint i.e. Django==4.2.8 in current case
# within the global constraint i.e. Django==3.2.21 in current case
# because we have global constraint of Django<4.2
django-version: ["pinned"]
django-version: ["pinned", "4.2"]
mongo-version: ["4"]
mysql-version: ["8"]
mysql-version: ["5.7", "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:
mongo:
image: mongo:${{ matrix.mongo-version }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
- "3.8"
django-version:
- "pinned"
- "4.2"
# When updating the shards, remember to make the same changes in
# .github/workflows/unit-tests-gh-hosted.yml
shard_name:
Expand Down
2 changes: 0 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,6 @@ compile-requirements: pre-requirements $(COMMON_CONSTRAINTS_TXT) ## Re-compile *
@# time someone tries to use the outputs.
sed '/^django-simple-history==/d' requirements/common_constraints.txt > requirements/common_constraints.tmp
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 install -r requirements/pip.txt

Expand Down
4 changes: 2 additions & 2 deletions cms/envs/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -1105,8 +1105,8 @@
}

DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'
DEFAULT_HASHING_ALGORITHM = 'sha256'

# This will be overridden through CMS config
DEFAULT_HASHING_ALGORITHM = 'sha1'
#################### Python sandbox ############################################

CODE_JAIL = {
Expand Down
4 changes: 2 additions & 2 deletions lms/envs/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -1768,8 +1768,8 @@ def _make_mako_template_dirs(settings):


DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'
DEFAULT_HASHING_ALGORITHM = 'sha256'

# This will be overridden through LMS config
DEFAULT_HASHING_ALGORITHM = 'sha1'
#################### Python sandbox ############################################

CODE_JAIL = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ def test_pinned_values(self):
"|HvGnjXf1b3jU"
"|ImExZWZiNzVlZGFmM2FkZWZmYjM4YjI0ZmZkOWU4MzExODU0MTk4NmVlNGRiYzBlODdhYWUzOGM5MzVlNzk4NjUi"
":1m6Hve"
":Pra4iochviPvKUoIV33gdVZFDgG-cMDlIYfl8iFIMaY"
":OMhY2FL2pudJjSSXChtI-zR8QVA"
)

@pytest.mark.skipif(django.VERSION[0] < 4, reason="For django42 default algorithm is sha256. No need for django32.")
Expand Down
32 changes: 10 additions & 22 deletions openedx/core/djangoapps/theming/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,41 +192,33 @@ def converter(matchobj):
This requires figuring out which files the matched URL resolves
to and calling the url() method of the storage.
"""
matches = matchobj.groupdict()
matched = matches["matched"]
url = matches["url"]
matched, url = matchobj.groups()

# Ignore absolute/protocol-relative and data-uri URLs.
if re.match(r"^[a-z]+:", url):
if re.match(r'^[a-z]+:', url):
return matched

# Ignore absolute URLs that don't point to a static file (dynamic
# 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

# Strip off the fragment so a path-like fragment won't interfere.
url_path, fragment = urldefrag(url)

# Ignore URLs without a path
if not url_path:
return matched

if url_path.startswith("/"):
if url_path.startswith('/'):
# Otherwise the condition above would have returned prematurely.
assert url_path.startswith(settings.STATIC_URL)
target_name = url_path[len(settings.STATIC_URL):]
else:
# 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)

# Determine the hashed name of the target file with the storage backend.
hashed_url = self._url(
self._stored_name,
unquote(target_name),
force=True,
hashed_files=hashed_files,
self._stored_name, unquote(target_name),
force=True, hashed_files=hashed_files,
)

# NOTE:
Expand All @@ -236,19 +228,15 @@ def converter(matchobj):
# The line is commented and not removed to make future django upgrade easier and show exactly what is
# 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.

# Restore the fragment that was stripped off earlier.
if fragment:
transformed_url += ("?#" if "?#" in url else "#") + fragment
transformed_url += ('?#' if '?#' in url else '#') + fragment

# Return the hashed version to the file
matches["url"] = unquote(transformed_url)
return template % matches
return template % unquote(transformed_url)

return converter

Expand Down
2 changes: 1 addition & 1 deletion requirements/common_constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@


# using LTS django version

Django<4.0

# 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
Expand Down
5 changes: 0 additions & 5 deletions requirements/constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,10 @@ click>=8.0,<9.0
# for them.
edx-enterprise==4.11.5

# 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
# mentioned on this issue https://github.com/openedx/edx-platform/issues/32884
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
# Major upgrade will be done in separate ticket.
Expand Down
9 changes: 4 additions & 5 deletions requirements/edx/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ backoff==1.10.0
backports-zoneinfo[tzdata]==0.2.1
# via
# celery
# django
# icalendar
# kombu
beautifulsoup4==4.12.3
Expand Down Expand Up @@ -174,9 +173,9 @@ defusedxml==0.7.1
# social-auth-core
deprecated==1.2.14
# via jwcrypto
django==4.2.9
django==3.2.23
# via
# -c requirements/edx/../constraints.txt
# -c requirements/edx/../common_constraints.txt
# -r requirements/edx/kernel.in
# django-appconf
# django-celery-results
Expand Down Expand Up @@ -339,7 +338,6 @@ django-ses==3.5.2
# via -r requirements/edx/bundled.in
django-simple-history==3.4.0
# via
# -c requirements/edx/../constraints.txt
# -r requirements/edx/kernel.in
# edx-enterprise
# edx-name-affirmation
Expand Down Expand Up @@ -433,7 +431,7 @@ edx-ccx-keys==1.2.1
# via
# -r requirements/edx/kernel.in
# lti-consumer-xblock
edx-celeryutils==1.2.5
edx-celeryutils==1.2.3
# via
# -r requirements/edx/kernel.in
# edx-name-affirmation
Expand Down Expand Up @@ -942,6 +940,7 @@ pytz==2023.4
# via
# -r requirements/edx/kernel.in
# babel
# django
# django-ses
# djangorestframework
# drf-yasg
Expand Down
9 changes: 4 additions & 5 deletions requirements/edx/development.txt
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ backports-zoneinfo[tzdata]==0.2.1
# -r requirements/edx/testing.txt
# backports-zoneinfo
# celery
# django
# icalendar
# kombu
beautifulsoup4==4.12.3
Expand Down Expand Up @@ -342,9 +341,9 @@ distlib==0.3.8
# via
# -r requirements/edx/testing.txt
# virtualenv
django==4.2.9
django==3.2.23
# via
# -c requirements/edx/../constraints.txt
# -c requirements/edx/../common_constraints.txt
# -r requirements/edx/doc.txt
# -r requirements/edx/testing.txt
# django-appconf
Expand Down Expand Up @@ -560,7 +559,6 @@ django-ses==3.5.2
# -r requirements/edx/testing.txt
django-simple-history==3.4.0
# via
# -c requirements/edx/../constraints.txt
# -r requirements/edx/doc.txt
# -r requirements/edx/testing.txt
# edx-enterprise
Expand Down Expand Up @@ -703,7 +701,7 @@ edx-ccx-keys==1.2.1
# -r requirements/edx/doc.txt
# -r requirements/edx/testing.txt
# lti-consumer-xblock
edx-celeryutils==1.2.5
edx-celeryutils==1.2.3
# via
# -r requirements/edx/doc.txt
# -r requirements/edx/testing.txt
Expand Down Expand Up @@ -1672,6 +1670,7 @@ pytz==2023.4
# -r requirements/edx/doc.txt
# -r requirements/edx/testing.txt
# babel
# django
# django-ses
# djangorestframework
# drf-yasg
Expand Down
9 changes: 4 additions & 5 deletions requirements/edx/doc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ backports-zoneinfo[tzdata]==0.2.1
# -r requirements/edx/base.txt
# backports-zoneinfo
# celery
# django
# icalendar
# kombu
beautifulsoup4==4.12.3
Expand Down Expand Up @@ -224,9 +223,9 @@ deprecated==1.2.14
# via
# -r requirements/edx/base.txt
# jwcrypto
django==4.2.9
django==3.2.23
# via
# -c requirements/edx/../constraints.txt
# -c requirements/edx/../common_constraints.txt
# -r requirements/edx/base.txt
# django-appconf
# django-celery-results
Expand Down Expand Up @@ -405,7 +404,6 @@ django-ses==3.5.2
# via -r requirements/edx/base.txt
django-simple-history==3.4.0
# via
# -c requirements/edx/../constraints.txt
# -r requirements/edx/base.txt
# edx-enterprise
# edx-name-affirmation
Expand Down Expand Up @@ -511,7 +509,7 @@ edx-ccx-keys==1.2.1
# via
# -r requirements/edx/base.txt
# lti-consumer-xblock
edx-celeryutils==1.2.5
edx-celeryutils==1.2.3
# via
# -r requirements/edx/base.txt
# edx-name-affirmation
Expand Down Expand Up @@ -1125,6 +1123,7 @@ pytz==2023.4
# via
# -r requirements/edx/base.txt
# babel
# django
# django-ses
# djangorestframework
# drf-yasg
Expand Down
9 changes: 4 additions & 5 deletions requirements/edx/testing.txt
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ backports-zoneinfo[tzdata]==0.2.1
# -r requirements/edx/base.txt
# backports-zoneinfo
# celery
# django
# icalendar
# kombu
beautifulsoup4==4.12.3
Expand Down Expand Up @@ -255,9 +254,9 @@ dill==0.3.8
# via pylint
distlib==0.3.8
# via virtualenv
django==4.2.9
django==3.2.23
# via
# -c requirements/edx/../constraints.txt
# -c requirements/edx/../common_constraints.txt
# -r requirements/edx/base.txt
# django-appconf
# django-celery-results
Expand Down Expand Up @@ -436,7 +435,6 @@ django-ses==3.5.2
# via -r requirements/edx/base.txt
django-simple-history==3.4.0
# via
# -c requirements/edx/../constraints.txt
# -r requirements/edx/base.txt
# edx-enterprise
# edx-name-affirmation
Expand Down Expand Up @@ -537,7 +535,7 @@ edx-ccx-keys==1.2.1
# via
# -r requirements/edx/base.txt
# lti-consumer-xblock
edx-celeryutils==1.2.5
edx-celeryutils==1.2.3
# via
# -r requirements/edx/base.txt
# edx-name-affirmation
Expand Down Expand Up @@ -1253,6 +1251,7 @@ pytz==2023.4
# via
# -r requirements/edx/base.txt
# babel
# django
# django-ses
# djangorestframework
# drf-yasg
Expand Down

0 comments on commit 23659d5

Please sign in to comment.