{"action":"created","comment":{"url":"https://api.github.com/repos/edx/edx-platform/pulls/comments/47292009","id":47292009,"diff_hunk":"@@ -94,9 +93,39 @@ def get_course_with_access(user, action, course_key, depth=0, check_if_enrolled=\n     check_if_enrolled: If true, additionally verifies that the user is either enrolled in the course\n       or has staff access.\n     \"\"\"\n-    assert isinstance(course_key, CourseKey)\n-    course = get_course_by_id(course_key, depth=depth)\n-    access_response = has_access(user, action, course, course_key)\n+    course = get_course_by_id(course_key, depth)\n+    check_course_access(course, user, action, check_if_enrolled)\n+    return course\n+\n+\n+def get_course_overview_with_access(user, action, course_key, check_if_enrolled=False):\n+    \"\"\"\n+    Given a course_key, look up the corresponding course overview,\n+    check that the user has the access to perform the specified action\n+    on the course, and return the course overview.\n+\n+    Raises a 404 if the course_key is invalid, or the user doesn't have access.\n+\n+    check_if_enrolled: If true, additionally verifies that the user is either enrolled in the course\n+      or has staff access.\n+    \"\"\"\n+    try:\n+        course_overview = CourseOverview.get_from_id(course_key)\n+    except CourseOverview.DoesNotExist:\n+        raise Http404(\"Course not found.\")\n+    check_course_access(course_overview, user, action, check_if_enrolled)\n+    return course_overview\n+\n+\n+def check_course_access(course, user, action, check_if_enrolled=False):","path":"lms/djangoapps/courseware/courses.py","position":55,"original_position":55,"commit_id":"76707af17198e631ea83b3359772c383c71e5311","original_commit_id":"76707af17198e631ea83b3359772c383c71e5311","user":{"login":"nasthagiri","id":6772826,"avatar_url":"https://avatars.githubusercontent.com/u/6772826?v=3","gravatar_id":"","url":"https://api.github.com/users/nasthagiri","html_url":"https://github.com/nasthagiri","followers_url":"https://api.github.com/users/nasthagiri/followers","following_url":"https://api.github.com/users/nasthagiri/following{/other_user}","gists_url":"https://api.github.com/users/nasthagiri/gists{/gist_id}","starred_url":"https://api.github.com/users/nasthagiri/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nasthagiri/subscriptions","organizations_url":"https://api.github.com/users/nasthagiri/orgs","repos_url":"https://api.github.com/users/nasthagiri/repos","events_url":"https://api.github.com/users/nasthagiri/events{/privacy}","received_events_url":"https://api.github.com/users/nasthagiri/received_events","type":"User","site_admin":false},"body":"As discussed, it's consistent with the function signatures of the related functions, although not consistent with the order inside the implementation.","created_at":"2015-12-10T21:55:08Z","updated_at":"2015-12-10T21:55:08Z","html_url":"https://github.com/edx/edx-platform/pull/10841#discussion_r47292009","pull_request_url":"https://api.github.com/repos/edx/edx-platform/pulls/10841","_links":{"self":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/comments/47292009"},"html":{"href":"https://github.com/edx/edx-platform/pull/10841#discussion_r47292009"},"pull_request":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/10841"}}},"pull_request":{"url":"https://api.github.com/repos/edx/edx-platform/pulls/10841","id":52742115,"html_url":"https://github.com/edx/edx-platform/pull/10841","diff_url":"https://github.com/edx/edx-platform/pull/10841.diff","patch_url":"https://github.com/edx/edx-platform/pull/10841.patch","issue_url":"https://api.github.com/repos/edx/edx-platform/issues/10841","number":10841,"state":"open","locked":false,"title":"Optimize Course Catalog using CourseOverview","user":{"login":"nasthagiri","id":6772826,"avatar_url":"https://avatars.githubusercontent.com/u/6772826?v=3","gravatar_id":"","url":"https://api.github.com/users/nasthagiri","html_url":"https://github.com/nasthagiri","followers_url":"https://api.github.com/users/nasthagiri/followers","following_url":"https://api.github.com/users/nasthagiri/following{/other_user}","gists_url":"https://api.github.com/users/nasthagiri/gists{/gist_id}","starred_url":"https://api.github.com/users/nasthagiri/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nasthagiri/subscriptions","organizations_url":"https://api.github.com/users/nasthagiri/orgs","repos_url":"https://api.github.com/users/nasthagiri/repos","events_url":"https://api.github.com/users/nasthagiri/events{/privacy}","received_events_url":"https://api.github.com/users/nasthagiri/received_events","type":"User","site_admin":false},"body":"This PR improves the performance of the Course Catalog API and the Course Catalog view for open edX instances by updating their code to retrieve information about the courses from CourseOverview data (in SQL) rather than through instantiated course modules from the modulestore (in MongoDB).\r\n\r\nThe following changes were made as part of this effort:\r\n* Added the following fields to `CourseOverview`: \r\n  * announcement\r\n  * catalog_visibility\r\n  * course_video_url\r\n  * effort\r\n  * short_description\r\n* Updated the Course index view to use CourseOverview.\r\n* Updated the Course Catalog and Course Detail APIs to use CourseOverview.\r\n  * Fixed the Course Detail API to check the correct permission.\r\n* Required the existence of CourseOverview models for each course in the system\r\n  * Introduced a `CourseOverviewGeneratedHistory` model to keep track of when the `CourseOverview` table is seeded with all courses in the system.\r\n  * Can be bootstrapped by calling the [generate_course_overview](https://github.com/edx/edx-platform/blob/master/openedx/core/djangoapps/content/course_overviews/management/commands/generate_course_overview.py) management command.\r\n  * But also now lazily computed, when needed.\r\n* Removed support for the outdated `ispublic` field on the Course Module, including its corresponding `ACCESS_REQUIRE_STAFF_FOR_COURSE` feature flag.\r\n* Removed unused function [get_course_university_about_section](https://github.com/edx/edx-platform/blob/master/lms/djangoapps/courseware/courses.py#L132).\r\n* Removed support for 'title', 'university', and 'number' from [get_course_about_section](https://github.com/edx/edx-platform/blob/master/lms/djangoapps/courseware/courses.py#L142) since they are no longer stored as course about HTML modules, and should instead be accessed directly from the Course Module.\r\n\r\n*Reviewers:* @ormsbee, @robrap \r\n*DevOps Reviewers:* @edx/devops \r\n*FYI:* @cahrens, @rlucioni ","created_at":"2015-12-05T01:25:33Z","updated_at":"2015-12-10T21:55:08Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3689003ac44a1998bbb1e1ffcb09550fa55672c2","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/edx/edx-platform/pulls/10841/commits","review_comments_url":"https://api.github.com/repos/edx/edx-platform/pulls/10841/comments","review_comment_url":"https://api.github.com/repos/edx/edx-platform/pulls/comments{/number}","comments_url":"https://api.github.com/repos/edx/edx-platform/issues/10841/comments","statuses_url":"https://api.github.com/repos/edx/edx-platform/statuses/76707af17198e631ea83b3359772c383c71e5311","head":{"label":"edx:mobile/optimize-course-api","ref":"mobile/optimize-course-api","sha":"76707af17198e631ea83b3359772c383c71e5311","user":{"login":"edx","id":3179841,"avatar_url":"https://avatars.githubusercontent.com/u/3179841?v=3","gravatar_id":"","url":"https://api.github.com/users/edx","html_url":"https://github.com/edx","followers_url":"https://api.github.com/users/edx/followers","following_url":"https://api.github.com/users/edx/following{/other_user}","gists_url":"https://api.github.com/users/edx/gists{/gist_id}","starred_url":"https://api.github.com/users/edx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edx/subscriptions","organizations_url":"https://api.github.com/users/edx/orgs","repos_url":"https://api.github.com/users/edx/repos","events_url":"https://api.github.com/users/edx/events{/privacy}","received_events_url":"https://api.github.com/users/edx/received_events","type":"Organization","site_admin":false},"repo":{"id":10391073,"name":"edx-platform","full_name":"edx/edx-platform","owner":{"login":"edx","id":3179841,"avatar_url":"https://avatars.githubusercontent.com/u/3179841?v=3","gravatar_id":"","url":"https://api.github.com/users/edx","html_url":"https://github.com/edx","followers_url":"https://api.github.com/users/edx/followers","following_url":"https://api.github.com/users/edx/following{/other_user}","gists_url":"https://api.github.com/users/edx/gists{/gist_id}","starred_url":"https://api.github.com/users/edx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edx/subscriptions","organizations_url":"https://api.github.com/users/edx/orgs","repos_url":"https://api.github.com/users/edx/repos","events_url":"https://api.github.com/users/edx/events{/privacy}","received_events_url":"https://api.github.com/users/edx/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/edx/edx-platform","description":"The Open edX platform, the software that powers edX!","fork":false,"url":"https://api.github.com/repos/edx/edx-platform","forks_url":"https://api.github.com/repos/edx/edx-platform/forks","keys_url":"https://api.github.com/repos/edx/edx-platform/keys{/key_id}","collaborators_url":"https://api.github.com/repos/edx/edx-platform/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/edx/edx-platform/teams","hooks_url":"https://api.github.com/repos/edx/edx-platform/hooks","issue_events_url":"https://api.github.com/repos/edx/edx-platform/issues/events{/number}","events_url":"https://api.github.com/repos/edx/edx-platform/events","assignees_url":"https://api.github.com/repos/edx/edx-platform/assignees{/user}","branches_url":"https://api.github.com/repos/edx/edx-platform/branches{/branch}","tags_url":"https://api.github.com/repos/edx/edx-platform/tags","blobs_url":"https://api.github.com/repos/edx/edx-platform/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/edx/edx-platform/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/edx/edx-platform/git/refs{/sha}","trees_url":"https://api.github.com/repos/edx/edx-platform/git/trees{/sha}","statuses_url":"https://api.github.com/repos/edx/edx-platform/statuses/{sha}","languages_url":"https://api.github.com/repos/edx/edx-platform/languages","stargazers_url":"https://api.github.com/repos/edx/edx-platform/stargazers","contributors_url":"https://api.github.com/repos/edx/edx-platform/contributors","subscribers_url":"https://api.github.com/repos/edx/edx-platform/subscribers","subscription_url":"https://api.github.com/repos/edx/edx-platform/subscription","commits_url":"https://api.github.com/repos/edx/edx-platform/commits{/sha}","git_commits_url":"https://api.github.com/repos/edx/edx-platform/git/commits{/sha}","comments_url":"https://api.github.com/repos/edx/edx-platform/comments{/number}","issue_comment_url":"https://api.github.com/repos/edx/edx-platform/issues/comments{/number}","contents_url":"https://api.github.com/repos/edx/edx-platform/contents/{+path}","compare_url":"https://api.github.com/repos/edx/edx-platform/compare/{base}...{head}","merges_url":"https://api.github.com/repos/edx/edx-platform/merges","archive_url":"https://api.github.com/repos/edx/edx-platform/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/edx/edx-platform/downloads","issues_url":"https://api.github.com/repos/edx/edx-platform/issues{/number}","pulls_url":"https://api.github.com/repos/edx/edx-platform/pulls{/number}","milestones_url":"https://api.github.com/repos/edx/edx-platform/milestones{/number}","notifications_url":"https://api.github.com/repos/edx/edx-platform/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/edx/edx-platform/labels{/name}","releases_url":"https://api.github.com/repos/edx/edx-platform/releases{/id}","created_at":"2013-05-30T20:20:38Z","updated_at":"2015-12-10T11:31:57Z","pushed_at":"2015-12-10T21:54:24Z","git_url":"git://github.com/edx/edx-platform.git","ssh_url":"git@github.com:edx/edx-platform.git","clone_url":"https://github.com/edx/edx-platform.git","svn_url":"https://github.com/edx/edx-platform","homepage":"http://open.edx.org/","size":605668,"stargazers_count":2291,"watchers_count":2291,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1399,"mirror_url":null,"open_issues_count":140,"forks":1399,"open_issues":140,"watchers":2291,"default_branch":"master"}},"base":{"label":"edx:master","ref":"master","sha":"a974cec3bee1cc22bbef30314210512dc48cbd0b","user":{"login":"edx","id":3179841,"avatar_url":"https://avatars.githubusercontent.com/u/3179841?v=3","gravatar_id":"","url":"https://api.github.com/users/edx","html_url":"https://github.com/edx","followers_url":"https://api.github.com/users/edx/followers","following_url":"https://api.github.com/users/edx/following{/other_user}","gists_url":"https://api.github.com/users/edx/gists{/gist_id}","starred_url":"https://api.github.com/users/edx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edx/subscriptions","organizations_url":"https://api.github.com/users/edx/orgs","repos_url":"https://api.github.com/users/edx/repos","events_url":"https://api.github.com/users/edx/events{/privacy}","received_events_url":"https://api.github.com/users/edx/received_events","type":"Organization","site_admin":false},"repo":{"id":10391073,"name":"edx-platform","full_name":"edx/edx-platform","owner":{"login":"edx","id":3179841,"avatar_url":"https://avatars.githubusercontent.com/u/3179841?v=3","gravatar_id":"","url":"https://api.github.com/users/edx","html_url":"https://github.com/edx","followers_url":"https://api.github.com/users/edx/followers","following_url":"https://api.github.com/users/edx/following{/other_user}","gists_url":"https://api.github.com/users/edx/gists{/gist_id}","starred_url":"https://api.github.com/users/edx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edx/subscriptions","organizations_url":"https://api.github.com/users/edx/orgs","repos_url":"https://api.github.com/users/edx/repos","events_url":"https://api.github.com/users/edx/events{/privacy}","received_events_url":"https://api.github.com/users/edx/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/edx/edx-platform","description":"The Open edX platform, the software that powers edX!","fork":false,"url":"https://api.github.com/repos/edx/edx-platform","forks_url":"https://api.github.com/repos/edx/edx-platform/forks","keys_url":"https://api.github.com/repos/edx/edx-platform/keys{/key_id}","collaborators_url":"https://api.github.com/repos/edx/edx-platform/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/edx/edx-platform/teams","hooks_url":"https://api.github.com/repos/edx/edx-platform/hooks","issue_events_url":"https://api.github.com/repos/edx/edx-platform/issues/events{/number}","events_url":"https://api.github.com/repos/edx/edx-platform/events","assignees_url":"https://api.github.com/repos/edx/edx-platform/assignees{/user}","branches_url":"https://api.github.com/repos/edx/edx-platform/branches{/branch}","tags_url":"https://api.github.com/repos/edx/edx-platform/tags","blobs_url":"https://api.github.com/repos/edx/edx-platform/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/edx/edx-platform/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/edx/edx-platform/git/refs{/sha}","trees_url":"https://api.github.com/repos/edx/edx-platform/git/trees{/sha}","statuses_url":"https://api.github.com/repos/edx/edx-platform/statuses/{sha}","languages_url":"https://api.github.com/repos/edx/edx-platform/languages","stargazers_url":"https://api.github.com/repos/edx/edx-platform/stargazers","contributors_url":"https://api.github.com/repos/edx/edx-platform/contributors","subscribers_url":"https://api.github.com/repos/edx/edx-platform/subscribers","subscription_url":"https://api.github.com/repos/edx/edx-platform/subscription","commits_url":"https://api.github.com/repos/edx/edx-platform/commits{/sha}","git_commits_url":"https://api.github.com/repos/edx/edx-platform/git/commits{/sha}","comments_url":"https://api.github.com/repos/edx/edx-platform/comments{/number}","issue_comment_url":"https://api.github.com/repos/edx/edx-platform/issues/comments{/number}","contents_url":"https://api.github.com/repos/edx/edx-platform/contents/{+path}","compare_url":"https://api.github.com/repos/edx/edx-platform/compare/{base}...{head}","merges_url":"https://api.github.com/repos/edx/edx-platform/merges","archive_url":"https://api.github.com/repos/edx/edx-platform/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/edx/edx-platform/downloads","issues_url":"https://api.github.com/repos/edx/edx-platform/issues{/number}","pulls_url":"https://api.github.com/repos/edx/edx-platform/pulls{/number}","milestones_url":"https://api.github.com/repos/edx/edx-platform/milestones{/number}","notifications_url":"https://api.github.com/repos/edx/edx-platform/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/edx/edx-platform/labels{/name}","releases_url":"https://api.github.com/repos/edx/edx-platform/releases{/id}","created_at":"2013-05-30T20:20:38Z","updated_at":"2015-12-10T11:31:57Z","pushed_at":"2015-12-10T21:54:24Z","git_url":"git://github.com/edx/edx-platform.git","ssh_url":"git@github.com:edx/edx-platform.git","clone_url":"https://github.com/edx/edx-platform.git","svn_url":"https://github.com/edx/edx-platform","homepage":"http://open.edx.org/","size":605668,"stargazers_count":2291,"watchers_count":2291,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1399,"mirror_url":null,"open_issues_count":140,"forks":1399,"open_issues":140,"watchers":2291,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/10841"},"html":{"href":"https://github.com/edx/edx-platform/pull/10841"},"issue":{"href":"https://api.github.com/repos/edx/edx-platform/issues/10841"},"comments":{"href":"https://api.github.com/repos/edx/edx-platform/issues/10841/comments"},"review_comments":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/10841/comments"},"review_comment":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/10841/commits"},"statuses":{"href":"https://api.github.com/repos/edx/edx-platform/statuses/76707af17198e631ea83b3359772c383c71e5311"}}}}