GitHub PullRequestReviewCommentEvent at 2014-11-07 08:01:22
Repository: edx-platform
Actor: e-kolpakov
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/open-craft/edx-platform/pulls/comments/19998266","id":19998266,"diff_hunk":"@@ -24,6 +28,30 @@ def has_course_access(user, course_key, role=CourseStaffRole):\n     return auth.has_access(user, role(course_key.for_branch(None)))\n \n \n+def has_write_access(user, course_key):\n+    \"\"\"\n+    Return True iff user is allowed to modify the given course/library.\n+    Currently equivalent to has_course_access but less amibguously named.\n+    \"\"\"\n+    return has_course_access(user, course_key)\n+\n+\n+def has_read_access(user, course_key):\n+    \"\"\"\n+    Return True iff user is allowed to view this course/library.\n+\n+    There is currently no such thing as read-only course access in studio, but\n+    there is read-only access to content libraries.\n+    \"\"\"\n+    if has_course_access(user, course_key):\n+        return True  # Global, Org, or Course \"Instructors\" and \"Staff\" can read and write\n+    if isinstance(course_key, LibraryLocator):\n+        if OrgLibraryUserRole(org=course_key.org).has_user(user):\n+            return True  # User has read-only access to all libraries in this organization\n+        return LibraryUserRole(course_key.for_branch(None)).has_user(user)  # User has read-only access this library","path":"cms/djangoapps/contentstore/views/access.py","position":36,"original_position":36,"commit_id":"5fb531205555f0441a2c55a3836c2dec9c71dd38","original_commit_id":"5fb531205555f0441a2c55a3836c2dec9c71dd38","user":{"login":"e-kolpakov","id":3330048,"avatar_url":"https://avatars.githubusercontent.com/u/3330048?v=2","gravatar_id":"","url":"https://api.github.com/users/e-kolpakov","html_url":"https://github.com/e-kolpakov","followers_url":"https://api.github.com/users/e-kolpakov/followers","following_url":"https://api.github.com/users/e-kolpakov/following{/other_user}","gists_url":"https://api.github.com/users/e-kolpakov/gists{/gist_id}","starred_url":"https://api.github.com/users/e-kolpakov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/e-kolpakov/subscriptions","organizations_url":"https://api.github.com/users/e-kolpakov/orgs","repos_url":"https://api.github.com/users/e-kolpakov/repos","events_url":"https://api.github.com/users/e-kolpakov/events{/privacy}","received_events_url":"https://api.github.com/users/e-kolpakov/received_events","type":"User","site_admin":false},"body":"Could be written as `OrgLibraryUserRole(org=course_key.org).has_user(user) or LibraryUserRole(course_key.for_branch(None)).has_user(user)`","created_at":"2014-11-07T08:01:22Z","updated_at":"2014-11-07T08:01:22Z","html_url":"https://github.com/open-craft/edx-platform/pull/8#discussion_r19998266","pull_request_url":"https://api.github.com/repos/open-craft/edx-platform/pulls/8","_links":{"self":{"href":"https://api.github.com/repos/open-craft/edx-platform/pulls/comments/19998266"},"html":{"href":"https://github.com/open-craft/edx-platform/pull/8#discussion_r19998266"},"pull_request":{"href":"https://api.github.com/repos/open-craft/edx-platform/pulls/8"}}},"pull_request":{"url":"https://api.github.com/repos/open-craft/edx-platform/pulls/8","id":24037968,"html_url":"https://github.com/open-craft/edx-platform/pull/8","diff_url":"https://github.com/open-craft/edx-platform/pull/8.diff","patch_url":"https://github.com/open-craft/edx-platform/pull/8.patch","issue_url":"https://api.github.com/repos/open-craft/edx-platform/issues/8","number":8,"state":"open","locked":false,"title":"Content libraries permissions","user":{"login":"bradenmacdonald","id":945577,"avatar_url":"https://avatars.githubusercontent.com/u/945577?v=2","gravatar_id":"","url":"https://api.github.com/users/bradenmacdonald","html_url":"https://github.com/bradenmacdonald","followers_url":"https://api.github.com/users/bradenmacdonald/followers","following_url":"https://api.github.com/users/bradenmacdonald/following{/other_user}","gists_url":"https://api.github.com/users/bradenmacdonald/gists{/gist_id}","starred_url":"https://api.github.com/users/bradenmacdonald/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bradenmacdonald/subscriptions","organizations_url":"https://api.github.com/users/bradenmacdonald/orgs","repos_url":"https://api.github.com/users/bradenmacdonald/repos","events_url":"https://api.github.com/users/bradenmacdonald/events{/privacy}","received_events_url":"https://api.github.com/users/bradenmacdonald/received_events","type":"User","site_admin":false},"body":"This pull request implements more fine-grained permissions for content libraries.\r\n\r\nThere are three roles that users can have:\r\n- **Instructor** (\"Instructor\" in LMS, \"Admin\" in studio): Can edit the library and its content, *and* can assign roles to other users.\r\n- **Staff**: Can edit the library and its content.\r\n- **LibraryUser**: New permission: read-only access to the library. Can use its content in other courses (and override settings when doing so), but cannot make any changes to the library itself nor its content.\r\n\r\n**No UI** has yet been implemented for assigning these roles to users, but you can see the tests for how to do it from code. You can also test it out by assigning roles manually - just ensure the django admin site is enabled, then go to http://localhost:8001/admin/student/courseaccessrole/ and create entries with role of `library_user` or `staff` or `instructor` and `course` equal to the library's key.\r\n\r\n**Note**: The permissions are currently not checked when the `refresh_children` method of `LibraryContentModule` does its thing. This will be implemented after the `Scope.settings` stuff is figured out (see #6), since it involved re-writing `refresh_children`.","created_at":"2014-11-07T07:48:16Z","updated_at":"2014-11-07T08:01:22Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1e2aa5ddf49bd5dc2f8b72a1c2227d1cb8ad2670","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/open-craft/edx-platform/pulls/8/commits","review_comments_url":"https://api.github.com/repos/open-craft/edx-platform/pulls/8/comments","review_comment_url":"https://api.github.com/repos/open-craft/edx-platform/pulls/comments/{number}","comments_url":"https://api.github.com/repos/open-craft/edx-platform/issues/8/comments","statuses_url":"https://api.github.com/repos/open-craft/edx-platform/statuses/5fb531205555f0441a2c55a3836c2dec9c71dd38","head":{"label":"open-craft:content-libraries-permissions","ref":"content-libraries-permissions","sha":"5fb531205555f0441a2c55a3836c2dec9c71dd38","user":{"login":"open-craft","id":7414786,"avatar_url":"https://avatars.githubusercontent.com/u/7414786?v=2","gravatar_id":"","url":"https://api.github.com/users/open-craft","html_url":"https://github.com/open-craft","followers_url":"https://api.github.com/users/open-craft/followers","following_url":"https://api.github.com/users/open-craft/following{/other_user}","gists_url":"https://api.github.com/users/open-craft/gists{/gist_id}","starred_url":"https://api.github.com/users/open-craft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/open-craft/subscriptions","organizations_url":"https://api.github.com/users/open-craft/orgs","repos_url":"https://api.github.com/users/open-craft/repos","events_url":"https://api.github.com/users/open-craft/events{/privacy}","received_events_url":"https://api.github.com/users/open-craft/received_events","type":"Organization","site_admin":false},"repo":{"id":19940883,"name":"edx-platform","full_name":"open-craft/edx-platform","owner":{"login":"open-craft","id":7414786,"avatar_url":"https://avatars.githubusercontent.com/u/7414786?v=2","gravatar_id":"","url":"https://api.github.com/users/open-craft","html_url":"https://github.com/open-craft","followers_url":"https://api.github.com/users/open-craft/followers","following_url":"https://api.github.com/users/open-craft/following{/other_user}","gists_url":"https://api.github.com/users/open-craft/gists{/gist_id}","starred_url":"https://api.github.com/users/open-craft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/open-craft/subscriptions","organizations_url":"https://api.github.com/users/open-craft/orgs","repos_url":"https://api.github.com/users/open-craft/repos","events_url":"https://api.github.com/users/open-craft/events{/privacy}","received_events_url":"https://api.github.com/users/open-craft/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/open-craft/edx-platform","description":"the edX learning management system (LMS) and course authoring tool, Studio","fork":true,"url":"https://api.github.com/repos/open-craft/edx-platform","forks_url":"https://api.github.com/repos/open-craft/edx-platform/forks","keys_url":"https://api.github.com/repos/open-craft/edx-platform/keys{/key_id}","collaborators_url":"https://api.github.com/repos/open-craft/edx-platform/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/open-craft/edx-platform/teams","hooks_url":"https://api.github.com/repos/open-craft/edx-platform/hooks","issue_events_url":"https://api.github.com/repos/open-craft/edx-platform/issues/events{/number}","events_url":"https://api.github.com/repos/open-craft/edx-platform/events","assignees_url":"https://api.github.com/repos/open-craft/edx-platform/assignees{/user}","branches_url":"https://api.github.com/repos/open-craft/edx-platform/branches{/branch}","tags_url":"https://api.github.com/repos/open-craft/edx-platform/tags","blobs_url":"https://api.github.com/repos/open-craft/edx-platform/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/open-craft/edx-platform/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/open-craft/edx-platform/git/refs{/sha}","trees_url":"https://api.github.com/repos/open-craft/edx-platform/git/trees{/sha}","statuses_url":"https://api.github.com/repos/open-craft/edx-platform/statuses/{sha}","languages_url":"https://api.github.com/repos/open-craft/edx-platform/languages","stargazers_url":"https://api.github.com/repos/open-craft/edx-platform/stargazers","contributors_url":"https://api.github.com/repos/open-craft/edx-platform/contributors","subscribers_url":"https://api.github.com/repos/open-craft/edx-platform/subscribers","subscription_url":"https://api.github.com/repos/open-craft/edx-platform/subscription","commits_url":"https://api.github.com/repos/open-craft/edx-platform/commits{/sha}","git_commits_url":"https://api.github.com/repos/open-craft/edx-platform/git/commits{/sha}","comments_url":"https://api.github.com/repos/open-craft/edx-platform/comments{/number}","issue_comment_url":"https://api.github.com/repos/open-craft/edx-platform/issues/comments/{number}","contents_url":"https://api.github.com/repos/open-craft/edx-platform/contents/{+path}","compare_url":"https://api.github.com/repos/open-craft/edx-platform/compare/{base}...{head}","merges_url":"https://api.github.com/repos/open-craft/edx-platform/merges","archive_url":"https://api.github.com/repos/open-craft/edx-platform/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/open-craft/edx-platform/downloads","issues_url":"https://api.github.com/repos/open-craft/edx-platform/issues{/number}","pulls_url":"https://api.github.com/repos/open-craft/edx-platform/pulls{/number}","milestones_url":"https://api.github.com/repos/open-craft/edx-platform/milestones{/number}","notifications_url":"https://api.github.com/repos/open-craft/edx-platform/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/open-craft/edx-platform/labels{/name}","releases_url":"https://api.github.com/repos/open-craft/edx-platform/releases{/id}","created_at":"2014-05-19T12:28:25Z","updated_at":"2014-10-24T06:49:07Z","pushed_at":"2014-11-07T07:39:41Z","git_url":"git://github.com/open-craft/edx-platform.git","ssh_url":"git@github.com:open-craft/edx-platform.git","clone_url":"https://github.com/open-craft/edx-platform.git","svn_url":"https://github.com/open-craft/edx-platform","homepage":"http://code.edx.org/","size":389215,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1,"mirror_url":null,"open_issues_count":2,"forks":1,"open_issues":2,"watchers":1,"default_branch":"master"}},"base":{"label":"open-craft:content-libraries-prototype","ref":"content-libraries-prototype","sha":"c60429a816c039d8881022d4a2c6f420b064e2fb","user":{"login":"open-craft","id":7414786,"avatar_url":"https://avatars.githubusercontent.com/u/7414786?v=2","gravatar_id":"","url":"https://api.github.com/users/open-craft","html_url":"https://github.com/open-craft","followers_url":"https://api.github.com/users/open-craft/followers","following_url":"https://api.github.com/users/open-craft/following{/other_user}","gists_url":"https://api.github.com/users/open-craft/gists{/gist_id}","starred_url":"https://api.github.com/users/open-craft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/open-craft/subscriptions","organizations_url":"https://api.github.com/users/open-craft/orgs","repos_url":"https://api.github.com/users/open-craft/repos","events_url":"https://api.github.com/users/open-craft/events{/privacy}","received_events_url":"https://api.github.com/users/open-craft/received_events","type":"Organization","site_admin":false},"repo":{"id":19940883,"name":"edx-platform","full_name":"open-craft/edx-platform","owner":{"login":"open-craft","id":7414786,"avatar_url":"https://avatars.githubusercontent.com/u/7414786?v=2","gravatar_id":"","url":"https://api.github.com/users/open-craft","html_url":"https://github.com/open-craft","followers_url":"https://api.github.com/users/open-craft/followers","following_url":"https://api.github.com/users/open-craft/following{/other_user}","gists_url":"https://api.github.com/users/open-craft/gists{/gist_id}","starred_url":"https://api.github.com/users/open-craft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/open-craft/subscriptions","organizations_url":"https://api.github.com/users/open-craft/orgs","repos_url":"https://api.github.com/users/open-craft/repos","events_url":"https://api.github.com/users/open-craft/events{/privacy}","received_events_url":"https://api.github.com/users/open-craft/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/open-craft/edx-platform","description":"the edX learning management system (LMS) and course authoring tool, Studio","fork":true,"url":"https://api.github.com/repos/open-craft/edx-platform","forks_url":"https://api.github.com/repos/open-craft/edx-platform/forks","keys_url":"https://api.github.com/repos/open-craft/edx-platform/keys{/key_id}","collaborators_url":"https://api.github.com/repos/open-craft/edx-platform/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/open-craft/edx-platform/teams","hooks_url":"https://api.github.com/repos/open-craft/edx-platform/hooks","issue_events_url":"https://api.github.com/repos/open-craft/edx-platform/issues/events{/number}","events_url":"https://api.github.com/repos/open-craft/edx-platform/events","assignees_url":"https://api.github.com/repos/open-craft/edx-platform/assignees{/user}","branches_url":"https://api.github.com/repos/open-craft/edx-platform/branches{/branch}","tags_url":"https://api.github.com/repos/open-craft/edx-platform/tags","blobs_url":"https://api.github.com/repos/open-craft/edx-platform/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/open-craft/edx-platform/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/open-craft/edx-platform/git/refs{/sha}","trees_url":"https://api.github.com/repos/open-craft/edx-platform/git/trees{/sha}","statuses_url":"https://api.github.com/repos/open-craft/edx-platform/statuses/{sha}","languages_url":"https://api.github.com/repos/open-craft/edx-platform/languages","stargazers_url":"https://api.github.com/repos/open-craft/edx-platform/stargazers","contributors_url":"https://api.github.com/repos/open-craft/edx-platform/contributors","subscribers_url":"https://api.github.com/repos/open-craft/edx-platform/subscribers","subscription_url":"https://api.github.com/repos/open-craft/edx-platform/subscription","commits_url":"https://api.github.com/repos/open-craft/edx-platform/commits{/sha}","git_commits_url":"https://api.github.com/repos/open-craft/edx-platform/git/commits{/sha}","comments_url":"https://api.github.com/repos/open-craft/edx-platform/comments{/number}","issue_comment_url":"https://api.github.com/repos/open-craft/edx-platform/issues/comments/{number}","contents_url":"https://api.github.com/repos/open-craft/edx-platform/contents/{+path}","compare_url":"https://api.github.com/repos/open-craft/edx-platform/compare/{base}...{head}","merges_url":"https://api.github.com/repos/open-craft/edx-platform/merges","archive_url":"https://api.github.com/repos/open-craft/edx-platform/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/open-craft/edx-platform/downloads","issues_url":"https://api.github.com/repos/open-craft/edx-platform/issues{/number}","pulls_url":"https://api.github.com/repos/open-craft/edx-platform/pulls{/number}","milestones_url":"https://api.github.com/repos/open-craft/edx-platform/milestones{/number}","notifications_url":"https://api.github.com/repos/open-craft/edx-platform/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/open-craft/edx-platform/labels{/name}","releases_url":"https://api.github.com/repos/open-craft/edx-platform/releases{/id}","created_at":"2014-05-19T12:28:25Z","updated_at":"2014-10-24T06:49:07Z","pushed_at":"2014-11-07T07:39:41Z","git_url":"git://github.com/open-craft/edx-platform.git","ssh_url":"git@github.com:open-craft/edx-platform.git","clone_url":"https://github.com/open-craft/edx-platform.git","svn_url":"https://github.com/open-craft/edx-platform","homepage":"http://code.edx.org/","size":389215,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1,"mirror_url":null,"open_issues_count":2,"forks":1,"open_issues":2,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/open-craft/edx-platform/pulls/8"},"html":{"href":"https://github.com/open-craft/edx-platform/pull/8"},"issue":{"href":"https://api.github.com/repos/open-craft/edx-platform/issues/8"},"comments":{"href":"https://api.github.com/repos/open-craft/edx-platform/issues/8/comments"},"review_comments":{"href":"https://api.github.com/repos/open-craft/edx-platform/pulls/8/comments"},"review_comment":{"href":"https://api.github.com/repos/open-craft/edx-platform/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/open-craft/edx-platform/pulls/8/commits"},"statuses":{"href":"https://api.github.com/repos/open-craft/edx-platform/statuses/5fb531205555f0441a2c55a3836c2dec9c71dd38"}}}}