Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/migrations-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ jobs:
# 'pinned' is used to install the latest patch version of Django
# 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", "4.2"]
django-version: ["pinned"]
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:
Expand Down
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ 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 @@ -1086,8 +1086,8 @@
}

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

# This will be overridden through CMS config
DEFAULT_HASHING_ALGORITHM = 'sha256'
#################### 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 @@ -1734,8 +1734,8 @@ def _make_mako_template_dirs(settings):


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

# This will be overridden through LMS config
DEFAULT_HASHING_ALGORITHM = 'sha256'
#################### 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"
":OMhY2FL2pudJjSSXChtI-zR8QVA"
":Pra4iochviPvKUoIV33gdVZFDgG-cMDlIYfl8iFIMaY"
)

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code is from django32. They have made some changes in django4.2. So updated this code also. Otherwise it gives errors with collectstatic command.

This is related PR

matched = matches["matched"]
url = matches["url"]

# 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)

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.
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:
# The line below was commented out so that absolute urls are used instead of relative urls to make themed
# assets work correctly.
#
# 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
return template % unquote(transformed_url)
matches["url"] = unquote(transformed_url)
return template % matches

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
3 changes: 3 additions & 0 deletions requirements/constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ djangorestframework-stubs==3.14.0 # Pinned to match django-stubs. Remove this w
# https://github.com/openedx/edx-platform/issues/31616
libsass==0.10.0

# incremental upgrade
django-simple-history==3.4.0

# greater version breaking upgrade builds
click==8.1.6

Expand Down
1 change: 1 addition & 0 deletions requirements/edx/development.txt
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,7 @@ django-ses==3.5.0
# -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