|
9 | 9 |
|
10 | 10 | from django.utils.translation import gettext as _ |
11 | 11 |
|
12 | | -from cms.djangoapps.contentstore.utils import reverse_usage_url |
13 | 12 | from common.djangoapps.util.db import MYSQL_MAX_INT, generate_int_id |
14 | 13 | from lms.lib.utils import get_parent_unit |
15 | 14 | from openedx.core.djangoapps.course_groups.partition_scheme import get_cohorted_user_partition |
@@ -118,6 +117,22 @@ def _get_usage_dict(course, unit, block, scheme_name=None): |
118 | 117 | """ |
119 | 118 | Get usage info for unit/block. |
120 | 119 | """ |
| 120 | + # MIGRATION NELC NOTE: |
| 121 | + # This import was originally at the top of the file: |
| 122 | + # from cms.djangoapps.contentstore.utils import reverse_usage_url |
| 123 | + # |
| 124 | + # However, when the LMS loads this module (because we force CMS signal |
| 125 | + # registration in LMS via `from cms.djangoapps.contentstore.signals import handlers`) in eox-nelp, |
| 126 | + # importing `reverse_usage_url` at the top level triggers dependencies on |
| 127 | + # `openedx.core.djangoapps.content.search`, which does not exist in the LMS |
| 128 | + # context. This causes runtime errors when starting LMS. |
| 129 | + # |
| 130 | + # To fix this, we moved the import into `_get_usage_dict`, which is the only |
| 131 | + # method that uses it. This way: |
| 132 | + # - In CMS, the function still works normally. |
| 133 | + # - In LMS, the import is never executed, avoiding the error. |
| 134 | + from cms.djangoapps.contentstore.utils import reverse_usage_url |
| 135 | + |
121 | 136 | parent_unit = get_parent_unit(block) |
122 | 137 |
|
123 | 138 | if unit == parent_unit and not block.has_children: |
|
0 commit comments