Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ __pycache__
/lib
/lib64

# node
node_modules
npm-debug.log

# Installer logs
pip-log.txt

Expand Down
4 changes: 4 additions & 0 deletions requirements/base.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,7 @@ nh3
oauthlib
openedx-django-pyfs
XBlock
# TODO: Run python reqs update
edx-opaque-keys
edx-django-utils>=5.14.1
edxval
Empty file.
26 changes: 26 additions & 0 deletions xblocks_contrib/utils/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
def display_name_with_default(block):
"""
Calculates the display name for a block.

Default to the display_name if it isn't None, else fall back to creating
a name based on the URL.

Unlike the rest of this module's functions, this function takes an entire
course block/overview as a parameter. This is because a few test cases
(specifically, {Text|Image|Video}AnnotationModuleTestCase.test_student_view)
create scenarios where course.display_name is not None but course.location
is None, which causes calling course.url_name to fail. So, although we'd
like to just pass course.display_name and course.url_name as arguments to
this function, we can't do so without breaking those tests.

Note: This method no longer escapes as it once did, so the caller must
ensure it is properly escaped where necessary.

Arguments:
block (XModuleMixin|CourseOverview|BlockStructureBlockData):
Block that is being accessed
"""
return (
block.display_name if block.display_name is not None
else block.scope_ids.usage_id.block_id.replace('_', ' ')
)
Loading
Loading