{"action":"created","comment":{"url":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/comments/63068215","id":63068215,"diff_hunk":"@@ -0,0 +1,46 @@\n+from nose.tools import *\n+\n+from scripts.migration.migrate_deleted_wikis import get_targets, migrate\n+\n+\n+from tests.base import OsfTestCase\n+from tests.factories import ProjectFactory, UserFactory, Auth\n+\n+class TestMigrateDeletedWikis(OsfTestCase):\n+    def setUp(self):\n+        super(TestMigrateDeletedWikis, self).setUp()\n+        self.user = UserFactory()\n+        self.auth = Auth(user=self.user)\n+        self.project = ProjectFactory(creator=self.user)\n+        # Update home wiki (which can't be deleted) an a second wiki\n+        self.project.update_node_wiki('home', 'Hello world', self.auth)\n+        self.project.update_node_wiki('second', 'Hola mundo', self.auth)\n+        self.project.update_node_wiki('second', 'Hola mundo 2', self.auth)\n+        # Delete the second wiki to populate targets\n+        self.project.delete_node_wiki('second', self.auth)","path":"scripts/tests/test_migrate_deleted_wikis.py","position":20,"original_position":20,"commit_id":"32db53c9600eb0b088dfce722bc055dd1daed4cb","original_commit_id":"32db53c9600eb0b088dfce722bc055dd1daed4cb","user":{"login":"brianjgeiger","id":6599111,"avatar_url":"https://avatars.githubusercontent.com/u/6599111?v=3","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":"Since you have the new code in delete_node_wiki, why isn't this call removing the wiki page versions?","created_at":"2016-05-12T18:05:55Z","updated_at":"2016-05-12T18:05:55Z","html_url":"https://github.com/CenterForOpenScience/osf.io/pull/5632#discussion_r63068215","pull_request_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/5632","_links":{"self":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/comments/63068215"},"html":{"href":"https://github.com/CenterForOpenScience/osf.io/pull/5632#discussion_r63068215"},"pull_request":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/5632"}}},"pull_request":{"url":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/5632","id":69518273,"html_url":"https://github.com/CenterForOpenScience/osf.io/pull/5632","diff_url":"https://github.com/CenterForOpenScience/osf.io/pull/5632.diff","patch_url":"https://github.com/CenterForOpenScience/osf.io/pull/5632.patch","issue_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues/5632","number":5632,"state":"open","locked":false,"title":"Create wiki without restoring deleted","user":{"login":"kch8qx","id":7120154,"avatar_url":"https://avatars.githubusercontent.com/u/7120154?v=3","gravatar_id":"","url":"https://api.github.com/users/kch8qx","html_url":"https://github.com/kch8qx","followers_url":"https://api.github.com/users/kch8qx/followers","following_url":"https://api.github.com/users/kch8qx/following{/other_user}","gists_url":"https://api.github.com/users/kch8qx/gists{/gist_id}","starred_url":"https://api.github.com/users/kch8qx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kch8qx/subscriptions","organizations_url":"https://api.github.com/users/kch8qx/orgs","repos_url":"https://api.github.com/users/kch8qx/repos","events_url":"https://api.github.com/users/kch8qx/events{/privacy}","received_events_url":"https://api.github.com/users/kch8qx/received_events","type":"User","site_admin":false},"body":"## Purpose\r\n\r\nCurrently, if you delete a wiki file, and then create a new wiki file with the same name as the deleted file, the new file still maintains all of the edits from the old file. These can be found under the 'Compare' panel in the project wiki. (In this example, \"hello\" has been created, edited, deleted, and re-created)\r\n![image](https://cloud.githubusercontent.com/assets/7120154/15150463/4c067e04-169b-11e6-88cd-7e7b75287595.png)\r\nThe purpose of this PR is when a user deletes a project wiki, the wiki (and all of its former edits) are permanently deleted. When a new wiki is created with the same name as a deleted wiki, it will not restore the old wiki's edits. (Again \"hello\" has  been created, edited, deleted, and re-created, but the old edits no longer persist in \"hello\"'s versions)\r\n![image](https://cloud.githubusercontent.com/assets/7120154/15150471/5344504c-169b-11e6-9188-03d5a5e58092.png)\r\n\r\n## Changes\r\n\r\nWhen a wiki is deleted currently, the page is just deleted from the project's wiki_pages_current. In order to prevent the deleted page from being restored when a new wiki of the same name is created, the page is now also deleted from the project's wiki_pages_versions upon deletion.\r\n\r\nThis change alone would only prevent newly deleted pages from being restored. If a user has already deleted a page before this change is made, and then creates a new wiki page of the same name, those previous edits would be restored. To fix this, this PR also includes a migration script that removes all wiki pages from a project's wiki_pages_versions that are not also pages in that project's wiki_pages_current. This prevents any page that has been deleted but does not currently exist as a project wiki from being restored when the user creates a new wiki page of the same name.\r\n\r\n\r\n\r\n## Side effects\r\n\r\nThere is really only one case (I can think of) that this PR wouldn't resolve. For example, let's say:\r\n1. You create a wiki page \"hello\"\r\n2. You make some edits to that page\r\n3. You delete that page\r\n4. You create another wiki page called \"hello\", and those previous edits have been restored\r\nThis PR will not retroactively un-restore those edits from the first version of \"hello\". Instead, if you now delete \"hello\", then create a new \"hello\" after this PR, the previous edits will not persist.\r\n\r\n## Ticket\r\n\r\nhttps://openscience.atlassian.net/browse/OSF-5968","created_at":"2016-05-10T14:41:56Z","updated_at":"2016-05-12T18:05:55Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7e1f96a9b8b526a9dedab678c1e351585f3cc367","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/5632/commits","review_comments_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/5632/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/5632/comments","statuses_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/statuses/32db53c9600eb0b088dfce722bc055dd1daed4cb","head":{"label":"kch8qx:create-wiki-without-restoring-deleted","ref":"create-wiki-without-restoring-deleted","sha":"32db53c9600eb0b088dfce722bc055dd1daed4cb","user":{"login":"kch8qx","id":7120154,"avatar_url":"https://avatars.githubusercontent.com/u/7120154?v=3","gravatar_id":"","url":"https://api.github.com/users/kch8qx","html_url":"https://github.com/kch8qx","followers_url":"https://api.github.com/users/kch8qx/followers","following_url":"https://api.github.com/users/kch8qx/following{/other_user}","gists_url":"https://api.github.com/users/kch8qx/gists{/gist_id}","starred_url":"https://api.github.com/users/kch8qx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kch8qx/subscriptions","organizations_url":"https://api.github.com/users/kch8qx/orgs","repos_url":"https://api.github.com/users/kch8qx/repos","events_url":"https://api.github.com/users/kch8qx/events{/privacy}","received_events_url":"https://api.github.com/users/kch8qx/received_events","type":"User","site_admin":false},"repo":{"id":41746383,"name":"osf.io","full_name":"kch8qx/osf.io","owner":{"login":"kch8qx","id":7120154,"avatar_url":"https://avatars.githubusercontent.com/u/7120154?v=3","gravatar_id":"","url":"https://api.github.com/users/kch8qx","html_url":"https://github.com/kch8qx","followers_url":"https://api.github.com/users/kch8qx/followers","following_url":"https://api.github.com/users/kch8qx/following{/other_user}","gists_url":"https://api.github.com/users/kch8qx/gists{/gist_id}","starred_url":"https://api.github.com/users/kch8qx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kch8qx/subscriptions","organizations_url":"https://api.github.com/users/kch8qx/orgs","repos_url":"https://api.github.com/users/kch8qx/repos","events_url":"https://api.github.com/users/kch8qx/events{/privacy}","received_events_url":"https://api.github.com/users/kch8qx/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/kch8qx/osf.io","description":"Facilitating Open Science","fork":true,"url":"https://api.github.com/repos/kch8qx/osf.io","forks_url":"https://api.github.com/repos/kch8qx/osf.io/forks","keys_url":"https://api.github.com/repos/kch8qx/osf.io/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kch8qx/osf.io/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kch8qx/osf.io/teams","hooks_url":"https://api.github.com/repos/kch8qx/osf.io/hooks","issue_events_url":"https://api.github.com/repos/kch8qx/osf.io/issues/events{/number}","events_url":"https://api.github.com/repos/kch8qx/osf.io/events","assignees_url":"https://api.github.com/repos/kch8qx/osf.io/assignees{/user}","branches_url":"https://api.github.com/repos/kch8qx/osf.io/branches{/branch}","tags_url":"https://api.github.com/repos/kch8qx/osf.io/tags","blobs_url":"https://api.github.com/repos/kch8qx/osf.io/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kch8qx/osf.io/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kch8qx/osf.io/git/refs{/sha}","trees_url":"https://api.github.com/repos/kch8qx/osf.io/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kch8qx/osf.io/statuses/{sha}","languages_url":"https://api.github.com/repos/kch8qx/osf.io/languages","stargazers_url":"https://api.github.com/repos/kch8qx/osf.io/stargazers","contributors_url":"https://api.github.com/repos/kch8qx/osf.io/contributors","subscribers_url":"https://api.github.com/repos/kch8qx/osf.io/subscribers","subscription_url":"https://api.github.com/repos/kch8qx/osf.io/subscription","commits_url":"https://api.github.com/repos/kch8qx/osf.io/commits{/sha}","git_commits_url":"https://api.github.com/repos/kch8qx/osf.io/git/commits{/sha}","comments_url":"https://api.github.com/repos/kch8qx/osf.io/comments{/number}","issue_comment_url":"https://api.github.com/repos/kch8qx/osf.io/issues/comments{/number}","contents_url":"https://api.github.com/repos/kch8qx/osf.io/contents/{+path}","compare_url":"https://api.github.com/repos/kch8qx/osf.io/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kch8qx/osf.io/merges","archive_url":"https://api.github.com/repos/kch8qx/osf.io/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kch8qx/osf.io/downloads","issues_url":"https://api.github.com/repos/kch8qx/osf.io/issues{/number}","pulls_url":"https://api.github.com/repos/kch8qx/osf.io/pulls{/number}","milestones_url":"https://api.github.com/repos/kch8qx/osf.io/milestones{/number}","notifications_url":"https://api.github.com/repos/kch8qx/osf.io/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kch8qx/osf.io/labels{/name}","releases_url":"https://api.github.com/repos/kch8qx/osf.io/releases{/id}","deployments_url":"https://api.github.com/repos/kch8qx/osf.io/deployments","created_at":"2015-09-01T15:19:43Z","updated_at":"2016-01-14T16:53:55Z","pushed_at":"2016-05-12T15:20:30Z","git_url":"git://github.com/kch8qx/osf.io.git","ssh_url":"git@github.com:kch8qx/osf.io.git","clone_url":"https://github.com/kch8qx/osf.io.git","svn_url":"https://github.com/kch8qx/osf.io","homepage":"http://osf.io","size":130093,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"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":"master"}},"base":{"label":"CenterForOpenScience:develop","ref":"develop","sha":"0377e69eff7c929158d22afd2560243a874708df","user":{"login":"CenterForOpenScience","id":3344584,"avatar_url":"https://avatars.githubusercontent.com/u/3344584?v=3","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://avatars.githubusercontent.com/u/3344584?v=3","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":"2016-05-11T04:52:41Z","pushed_at":"2016-05-12T17:12:30Z","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":"http://osf.io","size":275821,"stargazers_count":221,"watchers_count":221,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":167,"mirror_url":null,"open_issues_count":206,"forks":167,"open_issues":206,"watchers":221,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/5632"},"html":{"href":"https://github.com/CenterForOpenScience/osf.io/pull/5632"},"issue":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues/5632"},"comments":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues/5632/comments"},"review_comments":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/5632/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/5632/commits"},"statuses":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/statuses/32db53c9600eb0b088dfce722bc055dd1daed4cb"}}}}