Skip to content

Commit 69a09f6

Browse files
committed
chore: original code.
This commit contains original code copied from edx-platform. Purpose of keeping the first commit with original code is to get help in the review process. Reviewer just needs to open the second commit and code changes will be clearly visible.
1 parent 1811328 commit 69a09f6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+18063
-522
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ __pycache__
2323
/lib
2424
/lib64
2525

26+
# node
27+
node_modules
28+
npm-debug.log
29+
2630
# Installer logs
2731
pip-log.txt
2832

requirements/base.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,7 @@ nh3
88
oauthlib
99
openedx-django-pyfs
1010
XBlock
11+
# TODO: Run python reqs update
12+
edx-opaque-keys
13+
edx-django-utils>=5.14.1
14+
edxval

xblocks_contrib/utils/__init__.py

Whitespace-only changes.

xblocks_contrib/utils/utils.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
def display_name_with_default(block):
2+
"""
3+
Calculates the display name for a block.
4+
5+
Default to the display_name if it isn't None, else fall back to creating
6+
a name based on the URL.
7+
8+
Unlike the rest of this module's functions, this function takes an entire
9+
course block/overview as a parameter. This is because a few test cases
10+
(specifically, {Text|Image|Video}AnnotationModuleTestCase.test_student_view)
11+
create scenarios where course.display_name is not None but course.location
12+
is None, which causes calling course.url_name to fail. So, although we'd
13+
like to just pass course.display_name and course.url_name as arguments to
14+
this function, we can't do so without breaking those tests.
15+
16+
Note: This method no longer escapes as it once did, so the caller must
17+
ensure it is properly escaped where necessary.
18+
19+
Arguments:
20+
block (XModuleMixin|CourseOverview|BlockStructureBlockData):
21+
Block that is being accessed
22+
"""
23+
return (
24+
block.display_name if block.display_name is not None
25+
else block.scope_ids.usage_id.block_id.replace('_', ' ')
26+
)

0 commit comments

Comments
 (0)