-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[OldMongo FC-0004] Disable editing of Old Mongo courses in Studio #30933
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1485,6 +1485,12 @@ def test_course_overview_view_with_course(self): | |
"""Test viewing the course overview page with an existing course""" | ||
course = CourseFactory.create() | ||
resp = self._show_course_overview(course.id) | ||
|
||
# course_handler raise 404 for old mongo course | ||
if course.id.deprecated: | ||
self.assertEqual(resp.status_code, 404) | ||
return | ||
|
||
self.assertContains( | ||
resp, | ||
'<article class="outline outline-complex outline-course" data-locator="{locator}" data-course-key="{course_key}">'.format( # lint-amnesty, pylint: disable=line-too-long | ||
|
@@ -1550,6 +1556,12 @@ def test_get_html(handler): | |
course_key = course_items[0].id | ||
|
||
resp = self._show_course_overview(course_key) | ||
|
||
# course_handler raise 404 for old mongo course | ||
if course_key.deprecated: | ||
self.assertEqual(resp.status_code, 404) | ||
return | ||
|
||
self.assertEqual(resp.status_code, 200) | ||
self.assertContains(resp, 'Chapter 2') | ||
|
||
|
@@ -1879,6 +1891,9 @@ def post_rerun_request( | |
rerun_course_data.update(destination_course_data) | ||
destination_course_key = _get_course_id(self.store, destination_course_data) | ||
|
||
if destination_course_key.deprecated: | ||
raise SkipTest('OldMongo Deprecation') | ||
|
||
# post the request | ||
course_url = get_url('course_handler', destination_course_key, 'course_key_string') | ||
response = self.client.ajax_post(course_url, rerun_course_data) | ||
|
@@ -2198,6 +2213,9 @@ def _create_course(test, course_key, course_data): | |
""" | ||
Creates a course via an AJAX request and verifies the URL returned in the response. | ||
""" | ||
if course_key.deprecated: | ||
raise SkipTest('OldMongo Deprecation') | ||
Comment on lines
+2218
to
+2219
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you please add a comment explaining how/why this happens? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Skips is added due to the return of HttpResponseNotFound in course_handler for old mongo courses. Comment added. |
||
|
||
course_url = get_url('course_handler', course_key, 'course_key_string') | ||
response = test.client.ajax_post(course_url, course_data) | ||
test.assertEqual(response.status_code, 200) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -271,6 +271,11 @@ def course_handler(request, course_key_string=None): | |
json: delete this branch from this course (leaving off /branch/draft would imply delete the course) | ||
""" | ||
try: | ||
if course_key_string: | ||
course_key = CourseKey.from_string(course_key_string) | ||
if course_key.deprecated: | ||
logging.error(f"User {request.user.id} tried to access Studio for Old Mongo course {course_key}.") | ||
return HttpResponseNotFound() | ||
response_format = request.GET.get('format') or request.POST.get('format') or 'html' | ||
if response_format == 'json' or 'application/json' in request.META.get('HTTP_ACCEPT', 'application/json'): | ||
if request.method == 'GET': | ||
|
@@ -783,7 +788,7 @@ def format_course_for_view(course): | |
""" | ||
Return a dict of the data which the view requires for each course | ||
""" | ||
return { | ||
course_context = { | ||
'display_name': course.display_name, | ||
'course_key': str(course.location.course_key), | ||
'url': reverse_course_url('course_handler', course.id), | ||
|
@@ -793,6 +798,13 @@ def format_course_for_view(course): | |
'number': course.display_number_with_default, | ||
'run': course.location.run | ||
} | ||
if course.id.deprecated: | ||
course_context.update({ | ||
'url': None, | ||
'lms_link': None, | ||
'rerun_link': None | ||
}) | ||
return course_context | ||
Comment on lines
+801
to
+807
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I assume this is the code that results in: That text for the last course still looks clickable. Is that because it's still making the FYI @jmakowski1123, @JAAkana, @jristau1984 on how this is presented to the user. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ormsbee I may not be completely up to speed on what the end goal is for course authors, but if I'm reading this thread correctly, the Old Mongo courses are archived and only displaying in the Archived Courses tab as a means to mitigate cost, as opposed to disappearing completely. If that's the case, is the (what looks like?) a url to rerun the course also confusing for the author? Or can the course actually be rerun? Can authors access the archived content? If the answer to all of the above is no, then displaying all that text as grayed out is a better UX option I think? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In general, archived courses can be viewed in Studio. I think that the Old Mongo course is the last one here (with no "Re-run Course" or "View Live" link). Old Mongo courses will not be re-runnable or viewable after this merges. The fact that they show up in this list at all is to mitigate cost and risk. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @UvgenGen: Thank you for the update. @jmakowski1123, @jristau1984, @JAAkana: Unless there are objections by tomorrow, I'm planning to merge this PR with the UI pictured above (where Old Mongo courses display like the third course in the above screenshot). We can adjust the UI later if it's important to do so (e.g. add some kind of extra messaging?). If you believe this approach will impose too much of a burden on support teams and needs to be addressed immediately, please let me know. Again, the reason we're doing it this way is to make the smallest change possible to disable Studio access to these courses. Filtering out all Old Mongo courses at the database layer is a potentially very expensive operation (because the database tables are not properly indexed for that), and we're trying to avoid doing database migrations during this work to minimize risk. Cosmetic changes like the above where links are removed are simpler and have a much smaller chance of causing regressions elsewhere. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So @jristau1984 checked with Jon Fay:
Still waiting until TNL is fully staffed tomorrow before merge. |
||
|
||
in_process_action_course_keys = {uca.course_key for uca in in_process_course_actions} | ||
active_courses = [] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -446,9 +446,18 @@ def test_update_asides(self, block_type): | |
self.ASIDE_DATA_FIELD.field_name, self.ASIDE_DATA_FIELD.updated) | ||
|
||
|
||
@ddt.ddt | ||
class TestMongoDirectOnlyCategorySemantics(DirectOnlyCategorySemantics): | ||
""" | ||
Verify DIRECT_ONLY_CATEGORY semantics against the MongoModulestore | ||
""" | ||
MODULESTORE = TEST_DATA_MONGO_MODULESTORE | ||
__test__ = True | ||
|
||
@ddt.data(ModuleStoreEnum.Branch.draft_preferred, ModuleStoreEnum.Branch.published_only) | ||
def test_course_summaries(self, branch): | ||
""" Test that `get_course_summaries` method in modulestore work as expected. """ | ||
with self.store.branch_setting(branch_setting=branch): | ||
course_summaries = self.store.get_course_summaries() | ||
# get_course_summaries skip old mongo courses | ||
assert len(course_summaries) == 0 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The course summaries should still be generated for Old Mongo courses, shouldn't they? This was the basic metadata like display_name? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh yes you are right, course summaries should still be generated for Old Mongo courses. I'll update it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. updated |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we ever run a test here with the destination course key as an Old Mongo course? I didn't think our system ever supported re-running an Old Mongo course as another Old Mongo course, and if we have any tests that do that, we should probably remove them.
Could you please add a comment explaining how/why this happens?