refactor: Remove legacy course info page & related code

This commit is contained in:
Sagirov Eugeniy
2022-04-18 16:50:51 +03:00
parent 7f5d8e3511
commit 92ca176fde
41 changed files with 176 additions and 1406 deletions

View File

@@ -33,7 +33,7 @@ def print_course(course):
# course.tabs looks like this
# [{u'type': u'courseware'}, {u'type': u'course_info', u'name': u'Course Info'}, {u'type': u'textbooks'},
# [{u'type': u'courseware'}, {u'type': u'textbooks'},
# {u'type': u'discussion', u'name': u'Discussion'}, {u'type': u'wiki', u'name': u'Wiki'},
# {u'type': u'progress', u'name': u'Progress'}]
@@ -53,7 +53,7 @@ command again, adding --insert or --delete to edit the list.
course_help = '--course <id> required, e.g. Stanford/CS99/2013_spring'
delete_help = '--delete <tab-number>'
insert_help = '--insert <tab-number> <type> <name>, e.g. 4 "course_info" "Course Info"'
insert_help = '--insert <tab-number> <type> <name>, e.g. 4 "discussion" "Discussion"'
def add_arguments(self, parser):
parser.add_argument('--course',

View File

@@ -40,13 +40,13 @@ class BackfillCourseTabsTest(ModuleStoreTestCase):
course = CourseFactory()
course.tabs = [tab for tab in course.tabs if tab.type != 'dates']
self.update_course(course, ModuleStoreEnum.UserID.test)
assert len(course.tabs) == 6
assert len(course.tabs) == 5
assert 'dates' not in {tab.type for tab in course.tabs}
call_command('backfill_course_tabs')
course = self.store.get_course(course.id)
assert len(course.tabs) == 7
assert len(course.tabs) == 6
assert 'dates' in {tab.type for tab in course.tabs}
mock_logger.info.assert_any_call(f'Updating tabs for {course.id}.')
mock_logger.info.assert_any_call(f'Successfully updated tabs for {course.id}.')
@@ -66,16 +66,16 @@ class BackfillCourseTabsTest(ModuleStoreTestCase):
CourseFactory()
CourseFactory()
course = CourseFactory()
course.tabs = [tab for tab in course.tabs if tab.type in ('course_info', 'courseware')]
course.tabs = [tab for tab in course.tabs if tab.type == 'courseware']
self.update_course(course, ModuleStoreEnum.UserID.test)
assert len(course.tabs) == 2
assert len(course.tabs) == 1
assert 'dates' not in {tab.type for tab in course.tabs}
assert 'progress' not in {tab.type for tab in course.tabs}
call_command('backfill_course_tabs')
course = self.store.get_course(course.id)
assert len(course.tabs) == 7
assert len(course.tabs) == 6
assert 'dates' in {tab.type for tab in course.tabs}
assert 'progress' in {tab.type for tab in course.tabs}
mock_logger.info.assert_any_call('4 courses read from modulestore. Processing 0 to 4.')
@@ -99,8 +99,8 @@ class BackfillCourseTabsTest(ModuleStoreTestCase):
course_2 = CourseFactory()
course_2.tabs = [tab for tab in course_2.tabs if tab.type != 'progress']
self.update_course(course_2, ModuleStoreEnum.UserID.test)
assert len(course_1.tabs) == 6
assert len(course_2.tabs) == 6
assert len(course_1.tabs) == 5
assert len(course_2.tabs) == 5
assert 'dates' not in {tab.type for tab in course_1.tabs}
assert 'progress' not in {tab.type for tab in course_2.tabs}
@@ -108,8 +108,8 @@ class BackfillCourseTabsTest(ModuleStoreTestCase):
course_1 = self.store.get_course(course_1.id)
course_2 = self.store.get_course(course_2.id)
assert len(course_1.tabs) == 7
assert len(course_2.tabs) == 7
assert len(course_1.tabs) == 6
assert len(course_2.tabs) == 6
assert 'dates' in {tab.type for tab in course_1.tabs}
assert 'progress' in {tab.type for tab in course_2.tabs}
mock_logger.info.assert_any_call('2 courses read from modulestore. Processing 0 to 2.')
@@ -168,13 +168,13 @@ class BackfillCourseTabsTest(ModuleStoreTestCase):
def test_arguments_batching(self, start, count, expected_tabs_modified):
courses = CourseFactory.create_batch(4)
for course in courses:
course.tabs = [tab for tab in course.tabs if tab.type in ('course_info', 'courseware')]
course.tabs = [tab for tab in course.tabs if tab.type == 'courseware']
course = self.update_course(course, ModuleStoreEnum.UserID.test)
assert len(course.tabs) == 2
assert len(course.tabs) == 1
BackfillCourseTabsConfig.objects.create(enabled=True, start_index=start, count=count)
call_command('backfill_course_tabs')
for i, course in enumerate(courses):
course = self.store.get_course(course.id)
assert len(course.tabs) == (7 if expected_tabs_modified[i] else 2), f'Wrong tabs for course index {i}'
assert len(course.tabs) == (6 if expected_tabs_modified[i] else 1), f'Wrong tabs for course index {i}'

View File

@@ -173,7 +173,7 @@ class ContentStoreImportTest(ModuleStoreTestCase):
def test_tab_name_imports_correctly(self):
_module_store, _content_store, course = self.load_test_import_course()
print(f"course tabs = {course.tabs}")
self.assertEqual(course.tabs[2]['name'], 'Syllabus')
self.assertEqual(course.tabs[1]['name'], 'Syllabus')
def test_import_performance_mongo(self):
store = modulestore()._get_modulestore_by_type(ModuleStoreEnum.Type.mongo)

View File

@@ -220,8 +220,8 @@ def get_tab_by_locator(tab_list: List[CourseTab], tab_location: Union[str, Usage
def validate_args(num, tab_type):
"Throws for the disallowed cases."
if num <= 1:
raise ValueError('Tabs 1 and 2 cannot be edited')
if num < 1:
raise ValueError('Tab 1 cannot be edited')
if tab_type == 'static_tab':
raise ValueError('Tabs of type static_tab cannot be edited here (use Studio)')

View File

@@ -113,7 +113,7 @@ class TabsPageTests(CourseTestCase):
def test_reorder_tabs_invalid_tab(self):
"""Test re-ordering of tabs with invalid tab"""
invalid_tab_ids = ['courseware', 'info', 'invalid_tab_id']
invalid_tab_ids = ['courseware', 'invalid_tab_id']
# post the request
resp = self.client.ajax_post(
@@ -189,16 +189,14 @@ class PrimitiveTabEdit(ModuleStoreTestCase):
course = CourseFactory.create()
with self.assertRaises(ValueError):
tabs.primitive_delete(course, 0)
with self.assertRaises(ValueError):
tabs.primitive_delete(course, 1)
with self.assertRaises(IndexError):
tabs.primitive_delete(course, 7)
tabs.primitive_delete(course, 6)
assert course.tabs[2] != {'type': 'dates', 'name': 'Dates'}
tabs.primitive_delete(course, 2)
assert course.tabs[1] != {'type': 'dates', 'name': 'Dates'}
tabs.primitive_delete(course, 1)
assert {'type': 'progress'} not in course.tabs
# Check that dates has shifted up
assert course.tabs[2] == {'type': 'dates', 'name': 'Dates'}
assert course.tabs[1] == {'type': 'dates', 'name': 'Dates'}
def test_insert(self):
"""Test primitive tab insertion."""

View File

@@ -1661,9 +1661,6 @@ INSTALLED_APPS = [
# edx-milestones service
'milestones',
# Self-paced course configuration
'openedx.core.djangoapps.self_paced',
# Coursegraph
'cms.djangoapps.coursegraph.apps.CoursegraphConfig',