{"action":"created","comment":{"url":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/comments/137302921","pull_request_review_id":60952039,"id":137302921,"diff_hunk":"@@ -0,0 +1,275 @@\n+/**\n+ * Controller for deleting a node and it childs (if they exists)\n+ */\n+'use strict';\n+\n+var $ = require('jquery');\n+var $3 = window.$3;\n+var ko = require('knockout');\n+var Raven = require('raven-js');\n+var $osf = require('./osfHelpers');\n+var osfHelpers = require('js/osfHelpers');\n+var m = require('mithril');\n+var NodesDeleteTreebeard = require('js/nodesDeleteTreebeard');\n+\n+function _flattenNodeTree(nodeTree) {\n+    var ret = [];\n+    var stack = [nodeTree];\n+    while (stack.length) {\n+        var node = stack.pop();\n+        ret.push(node);\n+        stack = stack.concat(node.children);\n+    }\n+    return ret;\n+}\n+\n+/**\n+ * take treebeard tree structure of nodes and get a dictionary of parent node and all its\n+ * children\n+ */\n+function getNodesOriginal(nodeTree, nodesOriginal) {\n+    var flatNodes = _flattenNodeTree(nodeTree);\n+    $.each(flatNodes, function(_, nodeMeta) {\n+        nodesOriginal[nodeMeta.node.id] = {\n+            id: nodeMeta.node.id,\n+            title: nodeMeta.node.title,\n+            isAdmin: nodeMeta.node.is_admin,\n+            changed: false\n+        };\n+    });\n+    nodesOriginal[nodeTree.node.id].isRoot = true;\n+    return nodesOriginal;\n+}\n+\n+/**\n+ * patches all the nodes in a changed state\n+ * uses API v2 bulk requests\n+ */\n+function patchNodesDelete(nodes) {\n+    var nodesV2Url = window.contextVars.apiV2Prefix + 'nodes/';\n+    var nodesPatch = $.map(nodes, function (node) {\n+        return {\n+            'type': 'nodes',\n+            'id': node.id,\n+            'attributes': {\n+                'public': node.public","path":"website/static/js/nodesDelete.js","position":55,"original_position":55,"commit_id":"7487ed3567649baa4a68b3652eef01afa4f02dd9","original_commit_id":"7487ed3567649baa4a68b3652eef01afa4f02dd9","user":{"login":"brianjgeiger","id":6599111,"avatar_url":"https://avatars1.githubusercontent.com/u/6599111?v=4","gravatar_id":"","url":"https://api.github.com/users/brianjgeiger","html_url":"https://github.com/brianjgeiger","followers_url":"https://api.github.com/users/brianjgeiger/followers","following_url":"https://api.github.com/users/brianjgeiger/following{/other_user}","gists_url":"https://api.github.com/users/brianjgeiger/gists{/gist_id}","starred_url":"https://api.github.com/users/brianjgeiger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brianjgeiger/subscriptions","organizations_url":"https://api.github.com/users/brianjgeiger/orgs","repos_url":"https://api.github.com/users/brianjgeiger/repos","events_url":"https://api.github.com/users/brianjgeiger/events{/privacy}","received_events_url":"https://api.github.com/users/brianjgeiger/received_events","type":"User","site_admin":false},"body":"So I'm guessing you copied this from the bulk privacy changes. A delete request doesn't need this hefty of a payload.","created_at":"2017-09-06T15:29:48Z","updated_at":"2017-09-06T15:42:27Z","html_url":"https://github.com/CenterForOpenScience/osf.io/pull/7655#discussion_r137302921","pull_request_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/7655","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/comments/137302921"},"html":{"href":"https://github.com/CenterForOpenScience/osf.io/pull/7655#discussion_r137302921"},"pull_request":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/7655"}}},"pull_request":{"url":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/7655","id":139589005,"html_url":"https://github.com/CenterForOpenScience/osf.io/pull/7655","diff_url":"https://github.com/CenterForOpenScience/osf.io/pull/7655.diff","patch_url":"https://github.com/CenterForOpenScience/osf.io/pull/7655.patch","issue_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues/7655","number":7655,"state":"open","locked":false,"title":"[OSF-8516] Add a modal for deleting projects with components.","user":{"login":"adlius","id":1566880,"avatar_url":"https://avatars0.githubusercontent.com/u/1566880?v=4","gravatar_id":"","url":"https://api.github.com/users/adlius","html_url":"https://github.com/adlius","followers_url":"https://api.github.com/users/adlius/followers","following_url":"https://api.github.com/users/adlius/following{/other_user}","gists_url":"https://api.github.com/users/adlius/gists{/gist_id}","starred_url":"https://api.github.com/users/adlius/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adlius/subscriptions","organizations_url":"https://api.github.com/users/adlius/orgs","repos_url":"https://api.github.com/users/adlius/repos","events_url":"https://api.github.com/users/adlius/events{/privacy}","received_events_url":"https://api.github.com/users/adlius/received_events","type":"User","site_admin":false},"body":"## Purpose\r\n\r\nThis PR aims to improve the deletion process of projects with components by adding a helper modal to the front-end, enabling site users to choose delete all the components when deleting a project.\r\n\r\n## Changes\r\n\r\nThere are two parts to this PR. \r\n\r\nThe first part is a fix for the bulk deletion API. As of now, bulk deletion of a project and its components would fail even if all the components of the project are specified in postorder in the XHR request. The reason is that a database query to get all node instances does not preserve such order, resulting in error upon deleting nodes with undeleted child nodes.\r\n\r\nChanges made:\r\n1. In `api/base/generic_bulk_views.py`, `resource_object_list` is sorted according to the order specified in the request before returning.\r\n\r\nThe second part is a series of front end assets addition/modification for implementing the helper modal.\r\n\r\n1. Added `nodesDelete.js` as a controller for the modal. The KO viewmodel is also defined in this file.\r\n2. Added `nodes_delete.mako` as the template for the modal.\r\n3. Added `NodesDeleteTreebeard.js`, subclassing Treebeard to show the project hierarchy and handles user selection.\r\n4. `project-settings-page.js` is modified to initialize the modal when the current node has a child.\r\n5. `projectSettings.js` is modified to import `nodesDelete.js`.\r\n\r\n## Side effects\r\n\r\nFor the first part, sorting the list after the query may affect performance of the bulk deletion API. However the there seems to be no way to make the query preserve the order. Some thoughts on this are very much welcomed.\r\n\r\n\r\n## Ticket\r\n\r\nhttps://openscience.atlassian.net/browse/OSF-8516","created_at":"2017-09-06T15:10:47Z","updated_at":"2017-09-06T15:42:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"311a1cf034d88427465461daa1f8f2e435b29609","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/7655/commits","review_comments_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/7655/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/7655/comments","statuses_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/statuses/7487ed3567649baa4a68b3652eef01afa4f02dd9","head":{"label":"adlius:delete","ref":"delete","sha":"7487ed3567649baa4a68b3652eef01afa4f02dd9","user":{"login":"adlius","id":1566880,"avatar_url":"https://avatars0.githubusercontent.com/u/1566880?v=4","gravatar_id":"","url":"https://api.github.com/users/adlius","html_url":"https://github.com/adlius","followers_url":"https://api.github.com/users/adlius/followers","following_url":"https://api.github.com/users/adlius/following{/other_user}","gists_url":"https://api.github.com/users/adlius/gists{/gist_id}","starred_url":"https://api.github.com/users/adlius/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adlius/subscriptions","organizations_url":"https://api.github.com/users/adlius/orgs","repos_url":"https://api.github.com/users/adlius/repos","events_url":"https://api.github.com/users/adlius/events{/privacy}","received_events_url":"https://api.github.com/users/adlius/received_events","type":"User","site_admin":false},"repo":{"id":98200364,"name":"osf.io","full_name":"adlius/osf.io","owner":{"login":"adlius","id":1566880,"avatar_url":"https://avatars0.githubusercontent.com/u/1566880?v=4","gravatar_id":"","url":"https://api.github.com/users/adlius","html_url":"https://github.com/adlius","followers_url":"https://api.github.com/users/adlius/followers","following_url":"https://api.github.com/users/adlius/following{/other_user}","gists_url":"https://api.github.com/users/adlius/gists{/gist_id}","starred_url":"https://api.github.com/users/adlius/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adlius/subscriptions","organizations_url":"https://api.github.com/users/adlius/orgs","repos_url":"https://api.github.com/users/adlius/repos","events_url":"https://api.github.com/users/adlius/events{/privacy}","received_events_url":"https://api.github.com/users/adlius/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/adlius/osf.io","description":"Facilitating Open Science","fork":true,"url":"https://api.github.com/repos/adlius/osf.io","forks_url":"https://api.github.com/repos/adlius/osf.io/forks","keys_url":"https://api.github.com/repos/adlius/osf.io/keys{/key_id}","collaborators_url":"https://api.github.com/repos/adlius/osf.io/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/adlius/osf.io/teams","hooks_url":"https://api.github.com/repos/adlius/osf.io/hooks","issue_events_url":"https://api.github.com/repos/adlius/osf.io/issues/events{/number}","events_url":"https://api.github.com/repos/adlius/osf.io/events","assignees_url":"https://api.github.com/repos/adlius/osf.io/assignees{/user}","branches_url":"https://api.github.com/repos/adlius/osf.io/branches{/branch}","tags_url":"https://api.github.com/repos/adlius/osf.io/tags","blobs_url":"https://api.github.com/repos/adlius/osf.io/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/adlius/osf.io/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/adlius/osf.io/git/refs{/sha}","trees_url":"https://api.github.com/repos/adlius/osf.io/git/trees{/sha}","statuses_url":"https://api.github.com/repos/adlius/osf.io/statuses/{sha}","languages_url":"https://api.github.com/repos/adlius/osf.io/languages","stargazers_url":"https://api.github.com/repos/adlius/osf.io/stargazers","contributors_url":"https://api.github.com/repos/adlius/osf.io/contributors","subscribers_url":"https://api.github.com/repos/adlius/osf.io/subscribers","subscription_url":"https://api.github.com/repos/adlius/osf.io/subscription","commits_url":"https://api.github.com/repos/adlius/osf.io/commits{/sha}","git_commits_url":"https://api.github.com/repos/adlius/osf.io/git/commits{/sha}","comments_url":"https://api.github.com/repos/adlius/osf.io/comments{/number}","issue_comment_url":"https://api.github.com/repos/adlius/osf.io/issues/comments{/number}","contents_url":"https://api.github.com/repos/adlius/osf.io/contents/{+path}","compare_url":"https://api.github.com/repos/adlius/osf.io/compare/{base}...{head}","merges_url":"https://api.github.com/repos/adlius/osf.io/merges","archive_url":"https://api.github.com/repos/adlius/osf.io/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/adlius/osf.io/downloads","issues_url":"https://api.github.com/repos/adlius/osf.io/issues{/number}","pulls_url":"https://api.github.com/repos/adlius/osf.io/pulls{/number}","milestones_url":"https://api.github.com/repos/adlius/osf.io/milestones{/number}","notifications_url":"https://api.github.com/repos/adlius/osf.io/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/adlius/osf.io/labels{/name}","releases_url":"https://api.github.com/repos/adlius/osf.io/releases{/id}","deployments_url":"https://api.github.com/repos/adlius/osf.io/deployments","created_at":"2017-07-24T14:32:59Z","updated_at":"2017-07-24T14:33:20Z","pushed_at":"2017-09-06T15:41:20Z","git_url":"git://github.com/adlius/osf.io.git","ssh_url":"git@github.com:adlius/osf.io.git","clone_url":"https://github.com/adlius/osf.io.git","svn_url":"https://github.com/adlius/osf.io","homepage":"https://osf.io","size":159176,"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,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"develop"}},"base":{"label":"CenterForOpenScience:develop","ref":"develop","sha":"29f6ae57e642fff69bd6b3aaed9fae6c697b207c","user":{"login":"CenterForOpenScience","id":3344584,"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,"name":"osf.io","full_name":"CenterForOpenScience/osf.io","owner":{"login":"CenterForOpenScience","id":3344584,"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":"2017-08-29T18:15:08Z","pushed_at":"2017-09-06T15:41:22Z","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":159494,"stargazers_count":360,"watchers_count":360,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":231,"mirror_url":null,"open_issues_count":242,"forks":231,"open_issues":242,"watchers":360,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/7655"},"html":{"href":"https://github.com/CenterForOpenScience/osf.io/pull/7655"},"issue":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues/7655"},"comments":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues/7655/comments"},"review_comments":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/7655/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/7655/commits"},"statuses":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/statuses/7487ed3567649baa4a68b3652eef01afa4f02dd9"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"brianjgeiger"}}