{"action":"created","comment":{"url":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/comments/197933512","pull_request_review_id":131769917,"id":197933512,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDE5NzkzMzUxMg==","diff_hunk":"@@ -183,6 +186,22 @@ def wrapped(*args, **kwargs):\n     return wrapped\n \n \n+def check_can_download_preprint_file(user, node):\n+    \"\"\"View helper that returns whether a given user can download unpublished preprint files.\n+\n+    :rtype: boolean\n+    \"\"\"\n+    if not node.preprints.exists():\n+        return False\n+\n+    preprint = node.preprints.filter(guids___id=request.base_url.split('/')[-2]).first()\n+    provider = preprint.provider\n+\n+    is_admin_or_moderator = bool(user.groups.exclude(name__startswith='collections_') & Group.objects.filter(\n+        Q(name='reviews_{}_moderator'.format(provider._id)) | Q(name='reviews_{}_admin'.format(provider._id))))\n+\n+    return (provider.is_reviewed and is_admin_or_moderator) or user.has_perm('view_submissions', provider)","path":"website/project/decorators.py","position":28,"original_position":28,"commit_id":"3b0a9192d8c6a57b6156c5abedde379de388c3f0","original_commit_id":"3b0a9192d8c6a57b6156c5abedde379de388c3f0","user":{"login":"mfraezz","id":5659262,"node_id":"MDQ6VXNlcjU2NTkyNjI=","avatar_url":"https://avatars2.githubusercontent.com/u/5659262?v=4","gravatar_id":"","url":"https://api.github.com/users/mfraezz","html_url":"https://github.com/mfraezz","followers_url":"https://api.github.com/users/mfraezz/followers","following_url":"https://api.github.com/users/mfraezz/following{/other_user}","gists_url":"https://api.github.com/users/mfraezz/gists{/gist_id}","starred_url":"https://api.github.com/users/mfraezz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mfraezz/subscriptions","organizations_url":"https://api.github.com/users/mfraezz/orgs","repos_url":"https://api.github.com/users/mfraezz/repos","events_url":"https://api.github.com/users/mfraezz/events{/privacy}","received_events_url":"https://api.github.com/users/mfraezz/received_events","type":"User","site_admin":false},"body":"Two questions:\r\n1. Is this ever actually hit? `check_can_access` is only used by `check_contributor_auth`, which is used once by addons (completely unrelated) and by the `must_be_contributor`-type decorators. As far as I'm aware, the only case affected by the `download` kwarg is `resolve_guid_download`, which is unaffected by said decorators.\r\n2. If this was hit, wouldn't it block access to published preprints for... everyone other than a moderator? ","created_at":"2018-06-25T20:36:48Z","updated_at":"2018-06-25T20:41:51Z","html_url":"https://github.com/CenterForOpenScience/osf.io/pull/8481#discussion_r197933512","pull_request_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/8481","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/comments/197933512"},"html":{"href":"https://github.com/CenterForOpenScience/osf.io/pull/8481#discussion_r197933512"},"pull_request":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/8481"}}},"pull_request":{"url":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/8481","id":196839172,"node_id":"MDExOlB1bGxSZXF1ZXN0MTk2ODM5MTcy","html_url":"https://github.com/CenterForOpenScience/osf.io/pull/8481","diff_url":"https://github.com/CenterForOpenScience/osf.io/pull/8481.diff","patch_url":"https://github.com/CenterForOpenScience/osf.io/pull/8481.patch","issue_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues/8481","number":8481,"state":"open","locked":false,"title":"[IN-214][OSF] Allow superuser to download unpublished preprint","user":{"login":"fabmiz","id":4511563,"node_id":"MDQ6VXNlcjQ1MTE1NjM=","avatar_url":"https://avatars2.githubusercontent.com/u/4511563?v=4","gravatar_id":"","url":"https://api.github.com/users/fabmiz","html_url":"https://github.com/fabmiz","followers_url":"https://api.github.com/users/fabmiz/followers","following_url":"https://api.github.com/users/fabmiz/following{/other_user}","gists_url":"https://api.github.com/users/fabmiz/gists{/gist_id}","starred_url":"https://api.github.com/users/fabmiz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fabmiz/subscriptions","organizations_url":"https://api.github.com/users/fabmiz/orgs","repos_url":"https://api.github.com/users/fabmiz/repos","events_url":"https://api.github.com/users/fabmiz/events{/privacy}","received_events_url":"https://api.github.com/users/fabmiz/received_events","type":"User","site_admin":false},"body":"## Purpose\r\n\r\nAllow superuser to download unpublished preprint\r\n\r\n## Changes\r\n\r\nModify permissions check to include superuser perms check.\r\n\r\n## QA Notes\r\n\r\nEssentially these changes allow superuser to download unpublished\r\npreprints. But it also ensures submitter, moderator, and admin can download unpublished preprints\r\non branded and non-branded preprint providers.\r\n\r\n## Documentation\r\n\r\n\r\n## Side Effects\r\n\r\n<!-- Any possible side effects? -->\r\n\r\n## Ticket\r\n\r\n[[IN-215]](https://openscience.atlassian.net/browse/IN-215)","created_at":"2018-06-22T20:34:45Z","updated_at":"2018-06-25T20:41:51Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c7b8a9c830e2311f28eed2cb9772beb39ca50a0c","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/8481/commits","review_comments_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/8481/comments","review_comment_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/comments{/number}","comments_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues/8481/comments","statuses_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/statuses/3b0a9192d8c6a57b6156c5abedde379de388c3f0","head":{"label":"fabmiz:feature/IN-214","ref":"feature/IN-214","sha":"3b0a9192d8c6a57b6156c5abedde379de388c3f0","user":{"login":"fabmiz","id":4511563,"node_id":"MDQ6VXNlcjQ1MTE1NjM=","avatar_url":"https://avatars2.githubusercontent.com/u/4511563?v=4","gravatar_id":"","url":"https://api.github.com/users/fabmiz","html_url":"https://github.com/fabmiz","followers_url":"https://api.github.com/users/fabmiz/followers","following_url":"https://api.github.com/users/fabmiz/following{/other_user}","gists_url":"https://api.github.com/users/fabmiz/gists{/gist_id}","starred_url":"https://api.github.com/users/fabmiz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fabmiz/subscriptions","organizations_url":"https://api.github.com/users/fabmiz/orgs","repos_url":"https://api.github.com/users/fabmiz/repos","events_url":"https://api.github.com/users/fabmiz/events{/privacy}","received_events_url":"https://api.github.com/users/fabmiz/received_events","type":"User","site_admin":false},"repo":{"id":84862157,"node_id":"MDEwOlJlcG9zaXRvcnk4NDg2MjE1Nw==","name":"osf.io","full_name":"fabmiz/osf.io","owner":{"login":"fabmiz","id":4511563,"node_id":"MDQ6VXNlcjQ1MTE1NjM=","avatar_url":"https://avatars2.githubusercontent.com/u/4511563?v=4","gravatar_id":"","url":"https://api.github.com/users/fabmiz","html_url":"https://github.com/fabmiz","followers_url":"https://api.github.com/users/fabmiz/followers","following_url":"https://api.github.com/users/fabmiz/following{/other_user}","gists_url":"https://api.github.com/users/fabmiz/gists{/gist_id}","starred_url":"https://api.github.com/users/fabmiz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fabmiz/subscriptions","organizations_url":"https://api.github.com/users/fabmiz/orgs","repos_url":"https://api.github.com/users/fabmiz/repos","events_url":"https://api.github.com/users/fabmiz/events{/privacy}","received_events_url":"https://api.github.com/users/fabmiz/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/fabmiz/osf.io","description":"Facilitating Open Science","fork":true,"url":"https://api.github.com/repos/fabmiz/osf.io","forks_url":"https://api.github.com/repos/fabmiz/osf.io/forks","keys_url":"https://api.github.com/repos/fabmiz/osf.io/keys{/key_id}","collaborators_url":"https://api.github.com/repos/fabmiz/osf.io/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/fabmiz/osf.io/teams","hooks_url":"https://api.github.com/repos/fabmiz/osf.io/hooks","issue_events_url":"https://api.github.com/repos/fabmiz/osf.io/issues/events{/number}","events_url":"https://api.github.com/repos/fabmiz/osf.io/events","assignees_url":"https://api.github.com/repos/fabmiz/osf.io/assignees{/user}","branches_url":"https://api.github.com/repos/fabmiz/osf.io/branches{/branch}","tags_url":"https://api.github.com/repos/fabmiz/osf.io/tags","blobs_url":"https://api.github.com/repos/fabmiz/osf.io/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/fabmiz/osf.io/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/fabmiz/osf.io/git/refs{/sha}","trees_url":"https://api.github.com/repos/fabmiz/osf.io/git/trees{/sha}","statuses_url":"https://api.github.com/repos/fabmiz/osf.io/statuses/{sha}","languages_url":"https://api.github.com/repos/fabmiz/osf.io/languages","stargazers_url":"https://api.github.com/repos/fabmiz/osf.io/stargazers","contributors_url":"https://api.github.com/repos/fabmiz/osf.io/contributors","subscribers_url":"https://api.github.com/repos/fabmiz/osf.io/subscribers","subscription_url":"https://api.github.com/repos/fabmiz/osf.io/subscription","commits_url":"https://api.github.com/repos/fabmiz/osf.io/commits{/sha}","git_commits_url":"https://api.github.com/repos/fabmiz/osf.io/git/commits{/sha}","comments_url":"https://api.github.com/repos/fabmiz/osf.io/comments{/number}","issue_comment_url":"https://api.github.com/repos/fabmiz/osf.io/issues/comments{/number}","contents_url":"https://api.github.com/repos/fabmiz/osf.io/contents/{+path}","compare_url":"https://api.github.com/repos/fabmiz/osf.io/compare/{base}...{head}","merges_url":"https://api.github.com/repos/fabmiz/osf.io/merges","archive_url":"https://api.github.com/repos/fabmiz/osf.io/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/fabmiz/osf.io/downloads","issues_url":"https://api.github.com/repos/fabmiz/osf.io/issues{/number}","pulls_url":"https://api.github.com/repos/fabmiz/osf.io/pulls{/number}","milestones_url":"https://api.github.com/repos/fabmiz/osf.io/milestones{/number}","notifications_url":"https://api.github.com/repos/fabmiz/osf.io/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/fabmiz/osf.io/labels{/name}","releases_url":"https://api.github.com/repos/fabmiz/osf.io/releases{/id}","deployments_url":"https://api.github.com/repos/fabmiz/osf.io/deployments","created_at":"2017-03-13T18:42:50Z","updated_at":"2017-03-13T18:43:01Z","pushed_at":"2018-06-25T17:02:31Z","git_url":"git://github.com/fabmiz/osf.io.git","ssh_url":"git@github.com:fabmiz/osf.io.git","clone_url":"https://github.com/fabmiz/osf.io.git","svn_url":"https://github.com/fabmiz/osf.io","homepage":"https://osf.io","size":171842,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"develop"}},"base":{"label":"CenterForOpenScience:release/next-interfaces","ref":"release/next-interfaces","sha":"f689bef5fc7e69fe676bcc836a1704f997a0218b","user":{"login":"CenterForOpenScience","id":3344584,"node_id":"MDEyOk9yZ2FuaXphdGlvbjMzNDQ1ODQ=","avatar_url":"https://avatars1.githubusercontent.com/u/3344584?v=4","gravatar_id":"","url":"https://api.github.com/users/CenterForOpenScience","html_url":"https://github.com/CenterForOpenScience","followers_url":"https://api.github.com/users/CenterForOpenScience/followers","following_url":"https://api.github.com/users/CenterForOpenScience/following{/other_user}","gists_url":"https://api.github.com/users/CenterForOpenScience/gists{/gist_id}","starred_url":"https://api.github.com/users/CenterForOpenScience/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CenterForOpenScience/subscriptions","organizations_url":"https://api.github.com/users/CenterForOpenScience/orgs","repos_url":"https://api.github.com/users/CenterForOpenScience/repos","events_url":"https://api.github.com/users/CenterForOpenScience/events{/privacy}","received_events_url":"https://api.github.com/users/CenterForOpenScience/received_events","type":"Organization","site_admin":false},"repo":{"id":10199599,"node_id":"MDEwOlJlcG9zaXRvcnkxMDE5OTU5OQ==","name":"osf.io","full_name":"CenterForOpenScience/osf.io","owner":{"login":"CenterForOpenScience","id":3344584,"node_id":"MDEyOk9yZ2FuaXphdGlvbjMzNDQ1ODQ=","avatar_url":"https://avatars1.githubusercontent.com/u/3344584?v=4","gravatar_id":"","url":"https://api.github.com/users/CenterForOpenScience","html_url":"https://github.com/CenterForOpenScience","followers_url":"https://api.github.com/users/CenterForOpenScience/followers","following_url":"https://api.github.com/users/CenterForOpenScience/following{/other_user}","gists_url":"https://api.github.com/users/CenterForOpenScience/gists{/gist_id}","starred_url":"https://api.github.com/users/CenterForOpenScience/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CenterForOpenScience/subscriptions","organizations_url":"https://api.github.com/users/CenterForOpenScience/orgs","repos_url":"https://api.github.com/users/CenterForOpenScience/repos","events_url":"https://api.github.com/users/CenterForOpenScience/events{/privacy}","received_events_url":"https://api.github.com/users/CenterForOpenScience/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/CenterForOpenScience/osf.io","description":"Facilitating Open Science","fork":false,"url":"https://api.github.com/repos/CenterForOpenScience/osf.io","forks_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/forks","keys_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/keys{/key_id}","collaborators_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/teams","hooks_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/hooks","issue_events_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues/events{/number}","events_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/events","assignees_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/assignees{/user}","branches_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/branches{/branch}","tags_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/tags","blobs_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/git/refs{/sha}","trees_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/git/trees{/sha}","statuses_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/statuses/{sha}","languages_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/languages","stargazers_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/stargazers","contributors_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/contributors","subscribers_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/subscribers","subscription_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/subscription","commits_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/commits{/sha}","git_commits_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/git/commits{/sha}","comments_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/comments{/number}","issue_comment_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues/comments{/number}","contents_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/contents/{+path}","compare_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/compare/{base}...{head}","merges_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/merges","archive_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/downloads","issues_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues{/number}","pulls_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls{/number}","milestones_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/milestones{/number}","notifications_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/labels{/name}","releases_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/releases{/id}","deployments_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/deployments","created_at":"2013-05-21T15:53:37Z","updated_at":"2018-06-24T07:45:18Z","pushed_at":"2018-06-25T20:01:09Z","git_url":"git://github.com/CenterForOpenScience/osf.io.git","ssh_url":"git@github.com:CenterForOpenScience/osf.io.git","clone_url":"https://github.com/CenterForOpenScience/osf.io.git","svn_url":"https://github.com/CenterForOpenScience/osf.io","homepage":"https://osf.io","size":172433,"stargazers_count":448,"watchers_count":448,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":247,"mirror_url":null,"archived":false,"open_issues_count":226,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":247,"open_issues":226,"watchers":448,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/8481"},"html":{"href":"https://github.com/CenterForOpenScience/osf.io/pull/8481"},"issue":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues/8481"},"comments":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues/8481/comments"},"review_comments":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/8481/comments"},"review_comment":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/8481/commits"},"statuses":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/statuses/3b0a9192d8c6a57b6156c5abedde379de388c3f0"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"mfraezz"}}