Skip to content

Commit

Permalink
Merge branch 'master' into unpinpylint
Browse files Browse the repository at this point in the history
  • Loading branch information
irtazaakram committed Nov 19, 2024
2 parents 84c9c05 + c285714 commit 5775bbd
Show file tree
Hide file tree
Showing 13 changed files with 1,197 additions and 1,240 deletions.
2 changes: 1 addition & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: 2
build:
os: "ubuntu-22.04"
tools:
python: "3.12"
python: "3.11"

sphinx:
configuration: docs/conf.py
Expand Down
40 changes: 31 additions & 9 deletions cms/static/js/views/pages/container.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,14 @@ function($, _, Backbone, gettext, BasePage,

}

if (this.options.isIframeEmbed) {
window.addEventListener('message', (event) => {
if (event.data && event.data.type === 'refreshXBlock') {
this.render();
}
});
}

this.listenTo(Backbone, 'move:onXBlockMoved', this.onXBlockMoved);
},

Expand Down Expand Up @@ -625,26 +633,40 @@ function($, _, Backbone, gettext, BasePage,
},

showMoveXBlockModal: function(event) {
var xblockElement = this.findXBlockElement(event.target),
parentXBlockElement = xblockElement.parents('.studio-xblock-wrapper'),
sourceXBlockInfo = XBlockUtils.findXBlockInfo(xblockElement, this.model),
sourceParentXBlockInfo = XBlockUtils.findXBlockInfo(parentXBlockElement, this.model),
modal = new MoveXBlockModal({
sourceXBlockInfo: sourceXBlockInfo,
sourceParentXBlockInfo: sourceParentXBlockInfo,
XBlockURLRoot: this.getURLRoot(),
outlineURL: this.options.outlineURL
});

try {
if (this.options.isIframeEmbed) {
window.parent.postMessage(
{
type: 'showMoveXBlockModal',
payload: {}
payload: {
sourceXBlockInfo: {
id: sourceXBlockInfo.attributes.id,
displayName: sourceXBlockInfo.attributes.display_name,
},
sourceParentXBlockInfo: {
id: sourceParentXBlockInfo.attributes.id,
category: sourceParentXBlockInfo.attributes.category,
hasChildren: sourceParentXBlockInfo.attributes.has_children,
},
},
}, document.referrer
);
return true;
}
} catch (e) {
console.error(e);
}
var xblockElement = this.findXBlockElement(event.target),
parentXBlockElement = xblockElement.parents('.studio-xblock-wrapper'),
modal = new MoveXBlockModal({
sourceXBlockInfo: XBlockUtils.findXBlockInfo(xblockElement, this.model),
sourceParentXBlockInfo: XBlockUtils.findXBlockInfo(parentXBlockElement, this.model),
XBlockURLRoot: this.getURLRoot(),
outlineURL: this.options.outlineURL
});

event.preventDefault();
modal.show();
Expand Down
1 change: 1 addition & 0 deletions lms/djangoapps/certificates/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ def _format_certificate_for_user(username, cert):
if cert.status == CertificateStatuses.downloadable
else None
),
"uuid": cert.verify_uuid,
}

return None
Expand Down
35 changes: 24 additions & 11 deletions lms/djangoapps/certificates/apis/v0/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,17 +173,22 @@ def get_url(self, username):

def assert_success_response_for_student(self, response, download_url='www.google.com'):
""" This method is required by AuthAndScopesTestMixin. """
assert response.data ==\
[{'username': self.student.username,
'course_id': str(self.course.id),
'course_display_name': self.course.display_name,
'course_organization': self.course.org,
'certificate_type': CourseMode.VERIFIED,
'created_date': self.now,
'modified_date': self.now,
'status': CertificateStatuses.downloadable,
'is_passing': True,
'download_url': download_url, 'grade': '0.88'}]
assert response.data == [
{
'username': self.student.username,
'course_id': str(self.course.id),
'course_display_name': self.course.display_name,
'course_organization': self.course.org,
'certificate_type': CourseMode.VERIFIED,
'created_date': self.now,
'modified_date': self.now,
'status': CertificateStatuses.downloadable,
'is_passing': True,
'download_url': download_url,
'grade': '0.88',
'uuid': str(self.cert.verify_uuid)
}
]

@patch('edx_rest_framework_extensions.permissions.log')
@ddt.data(*list(AuthType))
Expand Down Expand Up @@ -212,6 +217,7 @@ def test_another_user_with_certs_shared_public(self, auth_type):

assert resp.status_code == status.HTTP_200_OK
assert len(resp.data) == 1
assert 'uuid' in resp.data[0]

def test_owner_can_access_its_certs(self):
"""
Expand All @@ -227,6 +233,7 @@ def test_owner_can_access_its_certs(self):

resp = self.get_response(AuthType.session, requesting_user=self.student)
assert resp.status_code == status.HTTP_200_OK
assert 'uuid' in resp.data[0]

# verifies that other than owner cert list api is not accessible
resp = self.get_response(AuthType.session, requesting_user=self.other_student)
Expand All @@ -246,12 +253,15 @@ def test_public_profile_certs_is_accessible(self):

resp = self.get_response(AuthType.session, requesting_user=self.student)
assert resp.status_code == status.HTTP_200_OK
assert 'uuid' in resp.data[0]

resp = self.get_response(AuthType.session, requesting_user=self.other_student)
assert resp.status_code == status.HTTP_200_OK
assert 'uuid' in resp.data[0]

resp = self.get_response(AuthType.session, requesting_user=self.global_staff)
assert resp.status_code == status.HTTP_200_OK
assert 'uuid' in resp.data[0]

@ddt.data(*list(AuthType))
def test_another_user_with_certs_shared_custom(self, auth_type):
Expand All @@ -276,6 +286,7 @@ def test_another_user_with_certs_shared_custom(self, auth_type):

assert resp.status_code == status.HTTP_200_OK
assert len(resp.data) == 1
assert 'uuid' in resp.data[0]

@patch('edx_rest_framework_extensions.permissions.log')
@ddt.data(*JWT_AUTH_TYPES)
Expand All @@ -290,6 +301,7 @@ def test_jwt_on_behalf_of_other_user(self, auth_type, mock_log):
else:
assert resp.status_code == status.HTTP_200_OK
assert len(resp.data) == 1
assert 'uuid' in resp.data[0]

@patch('edx_rest_framework_extensions.permissions.log')
@ddt.data(*JWT_AUTH_TYPES)
Expand Down Expand Up @@ -422,3 +434,4 @@ def test_certificate_without_course(self, mock_get_course_run_details):
assert response.status_code == status.HTTP_200_OK
self.assertContains(response, cert_for_deleted_course.download_url)
self.assertContains(response, expected_course_name)
assert 'uuid' in response.data[0]
1 change: 1 addition & 0 deletions lms/djangoapps/certificates/apis/v0/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ def get(self, request, username):
'is_passing': user_cert.get('is_passing'),
'download_url': user_cert.get('download_url'),
'grade': user_cert.get('grade'),
'uuid': user_cert.get('uuid'),
})
return Response(user_certs)

Expand Down
9 changes: 0 additions & 9 deletions lms/envs/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -2845,15 +2845,6 @@ def _make_locale_paths(settings): # pylint: disable=missing-function-docstring

################################# CELERY ######################################

# Until we've tested protocol 2, stay with protocol 1. It should be
# fine to just switch to protocol 2, since we're well past celery
# version 3.1.25 (the first version to support it) but we'll want to
# test this in a stage environment first.
#
# - Docs: https://docs.celeryq.dev/en/stable/history/whatsnew-4.0.html#new-task-message-protocol
# - Ticket: https://github.com/edx/edx-arch-experiments/issues/800
CELERY_TASK_PROTOCOL = 1

CELERY_IMPORTS = [
# Since xblock-poll is not a Django app, and XBlocks don't get auto-imported
# by celery workers, its tasks will not get auto-discovered:
Expand Down
Loading

0 comments on commit 5775bbd

Please sign in to comment.