Skip to content

Commit

Permalink
Merge branch 'master' into chris/advanced-editors-iframe
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisChV committed Jan 10, 2025
2 parents 57c76fa + 290209b commit 229d233
Show file tree
Hide file tree
Showing 81 changed files with 660 additions and 2,478 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pylint-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- module-name: openedx-2
path: "openedx/core/djangoapps/geoinfo/ openedx/core/djangoapps/header_control/ openedx/core/djangoapps/heartbeat/ openedx/core/djangoapps/lang_pref/ openedx/core/djangoapps/models/ openedx/core/djangoapps/monkey_patch/ openedx/core/djangoapps/oauth_dispatch/ openedx/core/djangoapps/olx_rest_api/ openedx/core/djangoapps/password_policy/ openedx/core/djangoapps/plugin_api/ openedx/core/djangoapps/plugins/ openedx/core/djangoapps/profile_images/ openedx/core/djangoapps/programs/ openedx/core/djangoapps/safe_sessions/ openedx/core/djangoapps/schedules/ openedx/core/djangoapps/service_status/ openedx/core/djangoapps/session_inactivity_timeout/ openedx/core/djangoapps/signals/ openedx/core/djangoapps/site_configuration/ openedx/core/djangoapps/system_wide_roles/ openedx/core/djangoapps/theming/ openedx/core/djangoapps/user_api/ openedx/core/djangoapps/user_authn/ openedx/core/djangoapps/util/ openedx/core/djangoapps/verified_track_content/ openedx/core/djangoapps/video_config/ openedx/core/djangoapps/video_pipeline/ openedx/core/djangoapps/waffle_utils/ openedx/core/djangoapps/xblock/ openedx/core/djangoapps/xmodule_django/ openedx/core/tests/ openedx/features/ openedx/testing/ openedx/tests/ openedx/core/djangoapps/notifications/ openedx/core/djangoapps/staticfiles/ openedx/core/djangoapps/content_tagging/"
- module-name: common
path: "common pavelib"
path: "common"
- module-name: cms
path: "cms"
- module-name: xmodule
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/unit-test-shards.json
Original file line number Diff line number Diff line change
Expand Up @@ -255,15 +255,13 @@
"common-with-lms": {
"settings": "lms.envs.test",
"paths": [
"common/djangoapps/",
"pavelib/"
"common/djangoapps/"
]
},
"common-with-cms": {
"settings": "cms.envs.test",
"paths": [
"common/djangoapps/",
"pavelib/"
"common/djangoapps/"
]
},
"xmodule-with-lms": {
Expand Down
37 changes: 12 additions & 25 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,29 +71,17 @@ jobs:

- name: install system requirements
run: |
sudo apt-get update && sudo apt-get install libmysqlclient-dev libxmlsec1-dev lynx openssl
# This is needed until the ENABLE_BLAKE2B_HASHING can be removed and we
# can stop using MD4 by default.
- name: enable md4 hashing in libssl
run: |
cat <<EOF | sudo tee /etc/ssl/openssl.cnf
# Use this in order to automatically load providers.
openssl_conf = openssl_init
[openssl_init]
providers = provider_sect
[provider_sect]
default = default_sect
legacy = legacy_sect
[default_sect]
activate = 1
[legacy_sect]
activate = 1
EOF
sudo apt-get update && sudo apt-get install libmysqlclient-dev libxmlsec1-dev lynx
# Try to log into DockerHub so that we're less likely to be rate-limited when pulling certain images.
# This will fail on any edx-platform fork which doesn't explicitly define its own DockerHub creds.
# That's OK--if we fail to log in, we'll proceed anonymously, and hope we don't get rate-limited.
- name: Try to log into Docker Hub
uses: docker/[email protected]
continue-on-error: true
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}

- name: Start MongoDB
uses: supercharge/[email protected]
Expand Down Expand Up @@ -180,7 +168,7 @@ jobs:
shell: bash
run: |
echo "root_cms_unit_tests_count=$(pytest --disable-warnings --collect-only --ds=cms.envs.test cms/ -q | head -n -2 | wc -l)" >> $GITHUB_ENV
echo "root_lms_unit_tests_count=$(pytest --disable-warnings --collect-only --ds=lms.envs.test lms/ openedx/ common/djangoapps/ xmodule/ pavelib/ -q | head -n -2 | wc -l)" >> $GITHUB_ENV
echo "root_lms_unit_tests_count=$(pytest --disable-warnings --collect-only --ds=lms.envs.test lms/ openedx/ common/djangoapps/ xmodule/ -q | head -n -2 | wc -l)" >> $GITHUB_ENV
- name: get GHA unit test paths
shell: bash
Expand Down Expand Up @@ -219,7 +207,6 @@ jobs:
to add any missing apps and match the count. for more details please take a look at scripts/gha-shards-readme.md"
exit 1
# This job aggregates test results. It's the required check for branch protection.
# https://github.com/marketplace/actions/alls-green#why
# https://github.com/orgs/community/discussions/33579
Expand Down
7 changes: 3 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ requirements: dev-requirements ## install development environment requirements
# Order is very important in this list: files must appear after everything they include!
REQ_FILES = \
requirements/edx/coverage \
requirements/edx/paver \
requirements/edx-sandbox/base \
requirements/edx/base \
requirements/edx/doc \
Expand Down Expand Up @@ -179,7 +178,7 @@ xsslint: ## check xss for quality issuest
--config=scripts.xsslint_config \
--thresholds=scripts/xsslint_thresholds.json

pycodestyle: ## check python files for quality issues
pycodestyle: ## check python files for quality issues
pycodestyle .

## Re-enable --lint flag when this issue https://github.com/openedx/edx-platform/issues/35775 is resolved
Expand All @@ -190,13 +189,13 @@ pii_check: ## check django models for pii annotations
--app_name cms \
--coverage \
--lint

DJANGO_SETTINGS_MODULE=lms.envs.test \
code_annotations django_find_annotations \
--config_file .pii_annotations.yml \
--app_name lms \
--coverage \
--lint
--lint

check_keywords: ## check django models for reserve keywords
DJANGO_SETTINGS_MODULE=cms.envs.test \
Expand Down
3 changes: 0 additions & 3 deletions cms/envs/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -566,9 +566,6 @@
# .. toggle_tickets: https://github.com/openedx/edx-platform/pull/33911
'ENABLE_GRADING_METHOD_IN_PROBLEMS': False,

# See annotations in lms/envs/common.py for details.
'ENABLE_BLAKE2B_HASHING': False,

# .. toggle_name: FEATURES['BADGES_ENABLED']
# .. toggle_implementation: DjangoSetting
# .. toggle_default: False
Expand Down
1 change: 1 addition & 0 deletions cms/static/js/views/components/add_library_content.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ function($, _, gettext, BaseModal) {
// Translators: "title" is the name of the current component being edited.
titleFormat: gettext('Add library content'),
addPrimaryActionButton: false,
showEditorModeButtons: false,
}),

initialize: function() {
Expand Down
1 change: 1 addition & 0 deletions cms/static/js/views/modals/select_v2_library_content.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ function($, _, gettext, BaseModal) {
viewSpecificClasses: 'modal-add-component-picker confirm',
titleFormat: gettext('Add library content'),
addPrimaryActionButton: false,
showEditorModeButtons: false,
}),

events: {
Expand Down
3 changes: 3 additions & 0 deletions cms/static/sass/views/_container.scss
Original file line number Diff line number Diff line change
Expand Up @@ -585,13 +585,16 @@
// cms/static/js/views/components/add_library_content_with_picker.js
.modal-add-component-picker {
top: 10%;
padding: 0px !important;
.modal-content {
padding: 0 !important;
border-radius: ($baseline/5);

& > iframe {
width: 100%;
min-height: 80vh;
background: url('#{$static-path}/images/spinner.gif') center center no-repeat;
border-radius: ($baseline/5);
}
}
}
Expand Down
28 changes: 15 additions & 13 deletions cms/templates/js/basic-modal.underscore
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,22 @@
<div class="modal-window-overlay"></div>
<div class="modal-window <%- viewSpecificClasses %> modal-<%- size %> modal-type-<%- type %>" tabindex="-1" aria-labelledby="modal-window-title">
<div class="<%- name %>-modal">
<div class="modal-header">
<h2 id="modal-window-title" class="title modal-window-title">
<%- title %>
<% if (modalSRTitle) { %>
<span class="sr modal-sr-title">
<%- modalSRTitle %>
</span>
<% if (title || modalSRTitle || showEditorModeButtons) { %>
<div class="modal-header">
<h2 id="modal-window-title" class="title modal-window-title">
<%- title %>
<% if (modalSRTitle) { %>
<span class="sr modal-sr-title">
<%- modalSRTitle %>
</span>
<% } %>
</h2>
<% if (showEditorModeButtons) { %>
<ul class="editor-modes action-list action-modes">
</ul>
<% } %>
</h2>
<% if (showEditorModeButtons) { %>
<ul class="editor-modes action-list action-modes">
</ul>
<% } %>
</div>
</div>
<% } %>
<div class="modal-content">
</div>
<div class="modal-actions">
Expand Down
2 changes: 2 additions & 0 deletions common/djangoapps/student/models/course_enrollment.py
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,8 @@ def enroll(cls, user, course_key, mode=None, check_access=False, can_upgrade=Fal
Also emits relevant events for analytics purposes.
"""
try:
# .. filter_implemented_name: CourseEnrollmentStarted
# .. filter_type: org.openedx.learning.course.enrollment.started.v1
user, course_key, mode = CourseEnrollmentStarted.run_filter(
user=user, course_key=course_key, mode=mode,
)
Expand Down
3 changes: 3 additions & 0 deletions common/djangoapps/student/views/management.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
from common.djangoapps.student.models import ( # lint-amnesty, pylint: disable=unused-import
AccountRecovery,
CourseEnrollment,
EnrollmentNotAllowed,
PendingEmailChange, # unimport:skip
PendingSecondaryEmailChange,
Registration,
Expand Down Expand Up @@ -422,6 +423,8 @@ def change_enrollment(request, check_access=True):
enroll_mode = CourseMode.auto_enroll_mode(course_id, available_modes)
if enroll_mode:
CourseEnrollment.enroll(user, course_id, check_access=check_access, mode=enroll_mode)
except EnrollmentNotAllowed as exc:
return HttpResponseBadRequest(str(exc))
except Exception: # pylint: disable=broad-except
return HttpResponseBadRequest(_("Could not enroll"))

Expand Down
6 changes: 1 addition & 5 deletions common/djangoapps/util/memcache.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,14 @@
import hashlib
from urllib.parse import quote_plus

from django.conf import settings
from django.utils.encoding import smart_str


def fasthash(string):
"""
Hashes `string` into a string representation of a 128-bit digest.
"""
if settings.FEATURES.get("ENABLE_BLAKE2B_HASHING", False):
hash_obj = hashlib.new("blake2b", digest_size=16)
else:
hash_obj = hashlib.new("md4")
hash_obj = hashlib.new("blake2b", digest_size=16)
hash_obj.update(string.encode('utf-8'))
return hash_obj.hexdigest()

Expand Down
48 changes: 1 addition & 47 deletions common/djangoapps/util/tests/test_memcache.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,11 @@
"""


from django.conf import settings
from django.core.cache import caches
from django.test import TestCase, override_settings
from django.test import TestCase

from common.djangoapps.util.memcache import safe_key

BLAKE2B_ENABLED_FEATURES = settings.FEATURES.copy()
BLAKE2B_ENABLED_FEATURES["ENABLE_BLAKE2B_HASHING"] = True


class MemcacheTest(TestCase):
"""
Expand Down Expand Up @@ -55,20 +51,6 @@ def test_safe_key_long(self):
# The key should now be valid
assert self._is_valid_key(key), f'Failed for key length {length}'

@override_settings(FEATURES=BLAKE2B_ENABLED_FEATURES)
def test_safe_key_long_with_blake2b_enabled(self):
# Choose lengths close to memcached's cutoff (250)
for length in [248, 249, 250, 251, 252]:

# Generate a key of that length
key = 'a' * length

# Make the key safe
key = safe_key(key, '', '')

# The key should now be valid
assert self._is_valid_key(key), f'Failed for key length {length}'

def test_long_key_prefix_version(self):

# Long key
Expand All @@ -83,34 +65,6 @@ def test_long_key_prefix_version(self):
key = safe_key('key', 'prefix', 'a' * 300)
assert self._is_valid_key(key)

@override_settings(FEATURES=BLAKE2B_ENABLED_FEATURES)
def test_long_key_prefix_version_with_blake2b_enabled(self):

# Long key
key = safe_key('a' * 300, 'prefix', 'version')
assert self._is_valid_key(key)

# Long prefix
key = safe_key('key', 'a' * 300, 'version')
assert self._is_valid_key(key)

# Long version
key = safe_key('key', 'prefix', 'a' * 300)
assert self._is_valid_key(key)

def test_safe_key_unicode(self):

for unicode_char in self.UNICODE_CHAR_CODES:

# Generate a key with that character
key = chr(unicode_char)

# Make the key safe
key = safe_key(key, '', '')

# The key should now be valid
assert self._is_valid_key(key), f'Failed for unicode character {unicode_char}'

def test_safe_key_prefix_unicode(self):

for unicode_char in self.UNICODE_CHAR_CODES:
Expand Down
Binary file modified common/static/data/geoip/GeoLite2-Country.mmdb
Binary file not shown.
6 changes: 5 additions & 1 deletion lms/djangoapps/bulk_email/signals.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
"""
Signal handlers for the bulk_email app
"""
import logging

from django.dispatch import receiver
from eventtracking import tracker

Expand All @@ -10,6 +12,8 @@

from .models import Optout

log = logging.getLogger(__name__)


@receiver(USER_RETIRE_MAILINGS)
def force_optout_all(sender, **kwargs): # lint-amnesty, pylint: disable=unused-argument
Expand Down Expand Up @@ -43,7 +47,7 @@ def ace_email_sent_handler(sender, **kwargs):
if not course_id:
course_email = context.get('course_email', None)
course_id = course_email.course_id if course_email else None

log.info(f'Email sent for {message_name} for course {course_id} using channel {channel}')
tracker.emit(
'edx.ace.message_sent',
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ def handle_goal(goal, today, sunday_date, monday_date, session_id):
'uuid': session_id,
'timestamp': datetime.now(),
'reason': 'User time zone',
'user_timezone': user_timezone,
'user_timezone': str(user_timezone),
'now_in_users_timezone': now_in_users_timezone,
}
)
Expand Down
11 changes: 0 additions & 11 deletions lms/djangoapps/grades/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,12 +467,6 @@ def update_or_create_grade(cls, **params):
defaults=params,
)

# TODO: Remove as part of EDUCATOR-4602.
if str(usage_key.course_key) == 'course-v1:UQx+BUSLEAD5x+2T2019':
log.info('Created/updated grade ***{}*** for user ***{}*** in course ***{}***'
'for subsection ***{}*** with default params ***{}***'
.format(grade, user_id, usage_key.course_key, usage_key, params))

grade.override = PersistentSubsectionGradeOverride.get_override(user_id, usage_key)
if first_attempted is not None and grade.first_attempted is None:
grade.first_attempted = first_attempted
Expand Down Expand Up @@ -822,11 +816,6 @@ def update_or_create_override(
grade_defaults['override_reason'] = override_data['comment'] if 'comment' in override_data else None
grade_defaults['system'] = override_data['system'] if 'system' in override_data else None

# TODO: Remove as part of EDUCATOR-4602.
if str(subsection_grade_model.course_id) == 'course-v1:UQx+BUSLEAD5x+2T2019':
log.info('Creating override for user ***{}*** for PersistentSubsectionGrade'
'***{}*** with override data ***{}*** and derived grade_defaults ***{}***.'
.format(requesting_user, subsection_grade_model, override_data, grade_defaults))
try:
override = PersistentSubsectionGradeOverride.objects.get(grade=subsection_grade_model)
for key, value in grade_defaults.items():
Expand Down
5 changes: 0 additions & 5 deletions lms/djangoapps/grades/rest_api/v1/gradebook_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -859,11 +859,6 @@ def post(self, request, course_key):
subsection = course.get_child(usage_key)
if subsection:
subsection_grade_model = self._create_subsection_grade(user, course, subsection)
# TODO: Remove as part of EDUCATOR-4602.
if str(course_key) == 'course-v1:UQx+BUSLEAD5x+2T2019':
log.info('PersistentSubsectionGrade ***{}*** created for'
' subsection ***{}*** in course ***{}*** for user ***{}***.'
.format(subsection_grade_model, subsection.location, course, user.id))
else:
self._log_update_result(request.user, requested_user_id, requested_usage_id, success=False)
result.append(GradebookUpdateResponseItem(
Expand Down
Loading

0 comments on commit 229d233

Please sign in to comment.