payload: {"action":"created","comment":{"url":"https://api.github.com/repos/edx/edx-ora2/pulls/comments/363888964","pull_request_review_id":339403116,"id":363888964,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDM2Mzg4ODk2NA==","diff_hunk":"@@ -53,6 +53,50 @@ def get_student_file_key(student_item_dict, index=0):\n     return key_template.format(index=index, **student_item_dict)\n \n \n+def can_delete_file(teams_enabled, key, team_id, shared_file=None):\n+    \"\"\"\n+    A user is allowed to delete any file they own if this is not a team-enabled response.\n+    If the response is team-enabled, a user, who is a member of a team,\n+    is allowed to delete a file they own as long as they are still\n+    a member of the team with which the file has been shared.\n+\n+    params:\n+      teams_enabled (boolean): Indicates if teams are enabled for an ORA block.\n+      key (string): The key of the file to check if we can delete.\n+      team_id (string): The id of the team of the user who may be able to delete the file.\n+      shared_file (SharedFileUpload): Optional. A SharedFileUpload object corresponding to the given\n+      key.  It's useful to pass this in if you've already fetched all of the SharedFileUpload records\n+      for a given item/team.\n+\n+    raises:\n+        SharedFileUpload.DoesNotExist If teams are enabled, a team_id is provided,\n+        and no SharedFileUpload corresponding to the file key exists.\n+    returns:\n+        Boolean indicating if the file with the given key can be deleted by the current user.\n+    \"\"\"\n+    if not teams_enabled:\n+        return True\n+\n+    if not shared_file:\n+        try:\n+            shared_file = SharedFileUpload.by_key(key)\n+        except SharedFileUpload.DoesNotExist:\n+            # TODO: is it reasonble to say \"fine, you can delete it, ugh!\"","path":"openassessment/fileupload/api.py","position":41,"original_position":41,"commit_id":"88301e0f42198736df04909e9fa0b565e17c0a81","original_commit_id":"88301e0f42198736df04909e9fa0b565e17c0a81","user":{"login":"jansenk","id":1639231,"node_id":"MDQ6VXNlcjE2MzkyMzE=","avatar_url":"https://avatars1.githubusercontent.com/u/1639231?v=4","gravatar_id":"","url":"https://api.github.com/users/jansenk","html_url":"https://github.com/jansenk","followers_url":"https://api.github.com/users/jansenk/followers","following_url":"https://api.github.com/users/jansenk/following{/other_user}","gists_url":"https://api.github.com/users/jansenk/gists{/gist_id}","starred_url":"https://api.github.com/users/jansenk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jansenk/subscriptions","organizations_url":"https://api.github.com/users/jansenk/orgs","repos_url":"https://api.github.com/users/jansenk/repos","events_url":"https://api.github.com/users/jansenk/events{/privacy}","received_events_url":"https://api.github.com/users/jansenk/received_events","type":"User","site_admin":false},"body":"Should we at least log a message? Not like that will really do anything ... maybe we should forcibly delete the file in this state xD","created_at":"2020-01-07T18:33:51Z","updated_at":"2020-01-07T18:47:19Z","html_url":"https://github.com/edx/edx-ora2/pull/1332#discussion_r363888964","pull_request_url":"https://api.github.com/repos/edx/edx-ora2/pulls/1332","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/edx/edx-ora2/pulls/comments/363888964"},"html":{"href":"https://github.com/edx/edx-ora2/pull/1332#discussion_r363888964"},"pull_request":{"href":"https://api.github.com/repos/edx/edx-ora2/pulls/1332"}}},"pull_request":{"url":"https://api.github.com/repos/edx/edx-ora2/pulls/1332","id":359128276,"node_id":"MDExOlB1bGxSZXF1ZXN0MzU5MTI4Mjc2","html_url":"https://github.com/edx/edx-ora2/pull/1332","diff_url":"https://github.com/edx/edx-ora2/pull/1332.diff","patch_url":"https://github.com/edx/edx-ora2/pull/1332.patch","issue_url":"https://api.github.com/repos/edx/edx-ora2/issues/1332","number":1332,"state":"open","locked":false,"title":"Control when learners can delete files as members of a team","user":{"login":"iloveagent57","id":2307986,"node_id":"MDQ6VXNlcjIzMDc5ODY=","avatar_url":"https://avatars2.githubusercontent.com/u/2307986?v=4","gravatar_id":"","url":"https://api.github.com/users/iloveagent57","html_url":"https://github.com/iloveagent57","followers_url":"https://api.github.com/users/iloveagent57/followers","following_url":"https://api.github.com/users/iloveagent57/following{/other_user}","gists_url":"https://api.github.com/users/iloveagent57/gists{/gist_id}","starred_url":"https://api.github.com/users/iloveagent57/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iloveagent57/subscriptions","organizations_url":"https://api.github.com/users/iloveagent57/orgs","repos_url":"https://api.github.com/users/iloveagent57/repos","events_url":"https://api.github.com/users/iloveagent57/events{/privacy}","received_events_url":"https://api.github.com/users/iloveagent57/received_events","type":"User","site_admin":false},"body":"https://openedx.atlassian.net/browse/EDUCATOR-4854\r\nhttps://openedx.atlassian.net/browse/EDUCATOR-4852\r\n\r\nThis also deletes the `FileUpload.url_descriptor_tuple()` method and transitions its responsibility to a new `FileUploadManager.all_descriptor_tuples()` method.  This new method takes team membership into account.","created_at":"2020-01-03T21:26:22Z","updated_at":"2020-01-07T18:47:19Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3afc10d677efc3a2fcca8a3ea6acbe35830cb0d6","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/edx/edx-ora2/pulls/1332/commits","review_comments_url":"https://api.github.com/repos/edx/edx-ora2/pulls/1332/comments","review_comment_url":"https://api.github.com/repos/edx/edx-ora2/pulls/comments{/number}","comments_url":"https://api.github.com/repos/edx/edx-ora2/issues/1332/comments","statuses_url":"https://api.github.com/repos/edx/edx-ora2/statuses/88301e0f42198736df04909e9fa0b565e17c0a81","head":{"label":"edx:aed/deletion-control","ref":"aed/deletion-control","sha":"88301e0f42198736df04909e9fa0b565e17c0a81","user":{"login":"edx","id":3179841,"node_id":"MDEyOk9yZ2FuaXphdGlvbjMxNzk4NDE=","avatar_url":"https://avatars3.githubusercontent.com/u/3179841?v=4","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":15404425,"node_id":"MDEwOlJlcG9zaXRvcnkxNTQwNDQyNQ==","name":"edx-ora2","full_name":"edx/edx-ora2","private":false,"owner":{"login":"edx","id":3179841,"node_id":"MDEyOk9yZ2FuaXphdGlvbjMxNzk4NDE=","avatar_url":"https://avatars3.githubusercontent.com/u/3179841?v=4","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},"html_url":"https://github.com/edx/edx-ora2","description":"Open Response Assessment Suite","fork":false,"url":"https://api.github.com/repos/edx/edx-ora2","forks_url":"https://api.github.com/repos/edx/edx-ora2/forks","keys_url":"https://api.github.com/repos/edx/edx-ora2/keys{/key_id}","collaborators_url":"https://api.github.com/repos/edx/edx-ora2/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/edx/edx-ora2/teams","hooks_url":"https://api.github.com/repos/edx/edx-ora2/hooks","issue_events_url":"https://api.github.com/repos/edx/edx-ora2/issues/events{/number}","events_url":"https://api.github.com/repos/edx/edx-ora2/events","assignees_url":"https://api.github.com/repos/edx/edx-ora2/assignees{/user}","branches_url":"https://api.github.com/repos/edx/edx-ora2/branches{/branch}","tags_url":"https://api.github.com/repos/edx/edx-ora2/tags","blobs_url":"https://api.github.com/repos/edx/edx-ora2/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/edx/edx-ora2/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/edx/edx-ora2/git/refs{/sha}","trees_url":"https://api.github.com/repos/edx/edx-ora2/git/trees{/sha}","statuses_url":"https://api.github.com/repos/edx/edx-ora2/statuses/{sha}","languages_url":"https://api.github.com/repos/edx/edx-ora2/languages","stargazers_url":"https://api.github.com/repos/edx/edx-ora2/stargazers","contributors_url":"https://api.github.com/repos/edx/edx-ora2/contributors","subscribers_url":"https://api.github.com/repos/edx/edx-ora2/subscribers","subscription_url":"https://api.github.com/repos/edx/edx-ora2/subscription","commits_url":"https://api.github.com/repos/edx/edx-ora2/commits{/sha}","git_commits_url":"https://api.github.com/repos/edx/edx-ora2/git/commits{/sha}","comments_url":"https://api.github.com/repos/edx/edx-ora2/comments{/number}","issue_comment_url":"https://api.github.com/repos/edx/edx-ora2/issues/comments{/number}","contents_url":"https://api.github.com/repos/edx/edx-ora2/contents/{+path}","compare_url":"https://api.github.com/repos/edx/edx-ora2/compare/{base}...{head}","merges_url":"https://api.github.com/repos/edx/edx-ora2/merges","archive_url":"https://api.github.com/repos/edx/edx-ora2/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/edx/edx-ora2/downloads","issues_url":"https://api.github.com/repos/edx/edx-ora2/issues{/number}","pulls_url":"https://api.github.com/repos/edx/edx-ora2/pulls{/number}","milestones_url":"https://api.github.com/repos/edx/edx-ora2/milestones{/number}","notifications_url":"https://api.github.com/repos/edx/edx-ora2/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/edx/edx-ora2/labels{/name}","releases_url":"https://api.github.com/repos/edx/edx-ora2/releases{/id}","deployments_url":"https://api.github.com/repos/edx/edx-ora2/deployments","created_at":"2013-12-23T20:54:54Z","updated_at":"2020-01-07T15:21:57Z","pushed_at":"2020-01-07T17:03:57Z","git_url":"git://github.com/edx/edx-ora2.git","ssh_url":"git@github.com:edx/edx-ora2.git","clone_url":"https://github.com/edx/edx-ora2.git","svn_url":"https://github.com/edx/edx-ora2","homepage":"","size":83051,"stargazers_count":40,"watchers_count":40,"language":"Python","has_issues":false,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":130,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":26,"license":{"key":"agpl-3.0","name":"GNU Affero General Public License v3.0","spdx_id":"AGPL-3.0","url":"https://api.github.com/licenses/agpl-3.0","node_id":"MDc6TGljZW5zZTE="},"forks":130,"open_issues":26,"watchers":40,"default_branch":"master"}},"base":{"label":"edx:master","ref":"master","sha":"23dd0bf0dcad7a6473428410710c192634f5ee75","user":{"login":"edx","id":3179841,"node_id":"MDEyOk9yZ2FuaXphdGlvbjMxNzk4NDE=","avatar_url":"https://avatars3.githubusercontent.com/u/3179841?v=4","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":15404425,"node_id":"MDEwOlJlcG9zaXRvcnkxNTQwNDQyNQ==","name":"edx-ora2","full_name":"edx/edx-ora2","private":false,"owner":{"login":"edx","id":3179841,"node_id":"MDEyOk9yZ2FuaXphdGlvbjMxNzk4NDE=","avatar_url":"https://avatars3.githubusercontent.com/u/3179841?v=4","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},"html_url":"https://github.com/edx/edx-ora2","description":"Open Response Assessment Suite","fork":false,"url":"https://api.github.com/repos/edx/edx-ora2","forks_url":"https://api.github.com/repos/edx/edx-ora2/forks","keys_url":"https://api.github.com/repos/edx/edx-ora2/keys{/key_id}","collaborators_url":"https://api.github.com/repos/edx/edx-ora2/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/edx/edx-ora2/teams","hooks_url":"https://api.github.com/repos/edx/edx-ora2/hooks","issue_events_url":"https://api.github.com/repos/edx/edx-ora2/issues/events{/number}","events_url":"https://api.github.com/repos/edx/edx-ora2/events","assignees_url":"https://api.github.com/repos/edx/edx-ora2/assignees{/user}","branches_url":"https://api.github.com/repos/edx/edx-ora2/branches{/branch}","tags_url":"https://api.github.com/repos/edx/edx-ora2/tags","blobs_url":"https://api.github.com/repos/edx/edx-ora2/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/edx/edx-ora2/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/edx/edx-ora2/git/refs{/sha}","trees_url":"https://api.github.com/repos/edx/edx-ora2/git/trees{/sha}","statuses_url":"https://api.github.com/repos/edx/edx-ora2/statuses/{sha}","languages_url":"https://api.github.com/repos/edx/edx-ora2/languages","stargazers_url":"https://api.github.com/repos/edx/edx-ora2/stargazers","contributors_url":"https://api.github.com/repos/edx/edx-ora2/contributors","subscribers_url":"https://api.github.com/repos/edx/edx-ora2/subscribers","subscription_url":"https://api.github.com/repos/edx/edx-ora2/subscription","commits_url":"https://api.github.com/repos/edx/edx-ora2/commits{/sha}","git_commits_url":"https://api.github.com/repos/edx/edx-ora2/git/commits{/sha}","comments_url":"https://api.github.com/repos/edx/edx-ora2/comments{/number}","issue_comment_url":"https://api.github.com/repos/edx/edx-ora2/issues/comments{/number}","contents_url":"https://api.github.com/repos/edx/edx-ora2/contents/{+path}","compare_url":"https://api.github.com/repos/edx/edx-ora2/compare/{base}...{head}","merges_url":"https://api.github.com/repos/edx/edx-ora2/merges","archive_url":"https://api.github.com/repos/edx/edx-ora2/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/edx/edx-ora2/downloads","issues_url":"https://api.github.com/repos/edx/edx-ora2/issues{/number}","pulls_url":"https://api.github.com/repos/edx/edx-ora2/pulls{/number}","milestones_url":"https://api.github.com/repos/edx/edx-ora2/milestones{/number}","notifications_url":"https://api.github.com/repos/edx/edx-ora2/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/edx/edx-ora2/labels{/name}","releases_url":"https://api.github.com/repos/edx/edx-ora2/releases{/id}","deployments_url":"https://api.github.com/repos/edx/edx-ora2/deployments","created_at":"2013-12-23T20:54:54Z","updated_at":"2020-01-07T15:21:57Z","pushed_at":"2020-01-07T17:03:57Z","git_url":"git://github.com/edx/edx-ora2.git","ssh_url":"git@github.com:edx/edx-ora2.git","clone_url":"https://github.com/edx/edx-ora2.git","svn_url":"https://github.com/edx/edx-ora2","homepage":"","size":83051,"stargazers_count":40,"watchers_count":40,"language":"Python","has_issues":false,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":130,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":26,"license":{"key":"agpl-3.0","name":"GNU Affero General Public License v3.0","spdx_id":"AGPL-3.0","url":"https://api.github.com/licenses/agpl-3.0","node_id":"MDc6TGljZW5zZTE="},"forks":130,"open_issues":26,"watchers":40,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/edx/edx-ora2/pulls/1332"},"html":{"href":"https://github.com/edx/edx-ora2/pull/1332"},"issue":{"href":"https://api.github.com/repos/edx/edx-ora2/issues/1332"},"comments":{"href":"https://api.github.com/repos/edx/edx-ora2/issues/1332/comments"},"review_comments":{"href":"https://api.github.com/repos/edx/edx-ora2/pulls/1332/comments"},"review_comment":{"href":"https://api.github.com/repos/edx/edx-ora2/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/edx/edx-ora2/pulls/1332/commits"},"statuses":{"href":"https://api.github.com/repos/edx/edx-ora2/statuses/88301e0f42198736df04909e9fa0b565e17c0a81"}},"author_association":"MEMBER"}}
other: {"actor":{"display_login":"jansenk"}}