Skip to content
Merged
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
17 changes: 16 additions & 1 deletion cms/djangoapps/contentstore/course_group_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

from django.utils.translation import gettext as _

from cms.djangoapps.contentstore.utils import reverse_usage_url
from common.djangoapps.util.db import MYSQL_MAX_INT, generate_int_id
from lms.lib.utils import get_parent_unit
from openedx.core.djangoapps.course_groups.partition_scheme import get_cohorted_user_partition
Expand Down Expand Up @@ -118,6 +117,22 @@ def _get_usage_dict(course, unit, block, scheme_name=None):
"""
Get usage info for unit/block.
"""
# MIGRATION NELC NOTE:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice notes, to help in the migration or future

# This import was originally at the top of the file:
# from cms.djangoapps.contentstore.utils import reverse_usage_url
#
# However, when the LMS loads this module (because we force CMS signal
# registration in LMS via `from cms.djangoapps.contentstore.signals import handlers`) in eox-nelp,
# importing `reverse_usage_url` at the top level triggers dependencies on
# `openedx.core.djangoapps.content.search`, which does not exist in the LMS
# context. This causes runtime errors when starting LMS.
#
# To fix this, we moved the import into `_get_usage_dict`, which is the only
# method that uses it. This way:
# - In CMS, the function still works normally.
# - In LMS, the import is never executed, avoiding the error.
from cms.djangoapps.contentstore.utils import reverse_usage_url

parent_unit = get_parent_unit(block)

if unit == parent_unit and not block.has_children:
Expand Down
Loading