{"action":"created","comment":{"url":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/comments/173952721","pull_request_review_id":103226672,"id":173952721,"diff_hunk":"@@ -1040,22 +1077,7 @@ def make_instance_obj(self, obj):\n     def update(self, instance, validated_data):\n         node = instance['self']\n         user = self.context['request'].user\n-\n-        add, remove = self.get_institutions_to_add_remove(\n-            institutions=instance['data'],\n-            new_institutions=validated_data['data']\n-        )\n-\n-        for inst in remove:\n-            if not user.is_affiliated_with_institution(inst) and not node.has_permission(user, 'admin'):","path":"api/nodes/serializers.py","position":149,"original_position":149,"commit_id":"499dc8e85f9918e62b0e8fa99f5412f3dff32cab","original_commit_id":"499dc8e85f9918e62b0e8fa99f5412f3dff32cab","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":"And here","created_at":"2018-03-12T21:28:55Z","updated_at":"2018-03-12T21:28:55Z","html_url":"https://github.com/CenterForOpenScience/osf.io/pull/8213#discussion_r173952721","pull_request_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/8213","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/comments/173952721"},"html":{"href":"https://github.com/CenterForOpenScience/osf.io/pull/8213#discussion_r173952721"},"pull_request":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/8213"}}},"pull_request":{"url":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/8213","id":174224266,"html_url":"https://github.com/CenterForOpenScience/osf.io/pull/8213","diff_url":"https://github.com/CenterForOpenScience/osf.io/pull/8213.diff","patch_url":"https://github.com/CenterForOpenScience/osf.io/pull/8213.patch","issue_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues/8213","number":8213,"state":"open","locked":false,"title":"[EMB-171] Handle toMany relationships for create/update in v2 api","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":"<!-- Before submit your Pull Request, make sure you picked\r\n     the right branch:\r\n\r\n     - For hotfixes, select \"master\" as the target branch\r\n     - For new features, select \"develop\" as the target branch\r\n     - For release feature fixes, select the relevant release branch (release/X.Y.Z) as the target branch -->\r\n\r\n## Purpose\r\n\r\nIn EmberOSF, we have some terrible hacks in to handle updating relationships that go to many relationships. In particular, the affiliated_institutions relationship on nodes. The reason is that the preferred method of updating that information, by including it in the relationship field of the POST or PATCH request, only worked with 1 to 1 relationships, such as Preprint->Node or Node->License. This generalizes everything to allow that to work with toMany relationships, and in particular adds support for Node->affiliated_institutions.\r\n\r\n## Changes\r\n\r\n1. Update parsers to handle lists\r\n2. Update affiliated_institutions field to be writeable, not be required, and have \"many\"\r\n3. Update base serializer to handle where everything broke when \"many\" was activated (mostly related to not realizing that fields also have child_relations that need to be checked)\r\n4. Add parser classes to node list view so creation worked\r\n5. Update tests to handle relationships that were lists\r\n\r\n## QA Notes\r\n\r\nIf preprints creation/updating still works, then this should all be fine. We aren't using the multiple feature until the Dashboard is in, and it's mostly making sure the rest of the API didn't break.  Any runscope tests that create or patch with relationships (preprints or node licenses) would be good to run as well, though we have pretty thorough test coverage on this.\r\n\r\n## Side Effects\r\n\r\nPotentially. The most suspicious change was overriding the `to_internal_value` method on the Relationship field, which was weird that it hadn't been necessary before but is now. I suspect it's somehow related to having that field be accessed indirectly with `child_relations`.\r\n\r\n## Ticket\r\n\r\nhttps://openscience.atlassian.net/browse/EMB-171\r\n","created_at":"2018-03-11T14:41:15Z","updated_at":"2018-03-12T21:28:55Z","closed_at":null,"merged_at":null,"merge_commit_sha":"084ac772b21a6b427c02642c9761c8de98fbd98d","assignee":{"login":"sloria","id":2379650,"avatar_url":"https://avatars2.githubusercontent.com/u/2379650?v=4","gravatar_id":"","url":"https://api.github.com/users/sloria","html_url":"https://github.com/sloria","followers_url":"https://api.github.com/users/sloria/followers","following_url":"https://api.github.com/users/sloria/following{/other_user}","gists_url":"https://api.github.com/users/sloria/gists{/gist_id}","starred_url":"https://api.github.com/users/sloria/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sloria/subscriptions","organizations_url":"https://api.github.com/users/sloria/orgs","repos_url":"https://api.github.com/users/sloria/repos","events_url":"https://api.github.com/users/sloria/events{/privacy}","received_events_url":"https://api.github.com/users/sloria/received_events","type":"User","site_admin":false},"assignees":[{"login":"sloria","id":2379650,"avatar_url":"https://avatars2.githubusercontent.com/u/2379650?v=4","gravatar_id":"","url":"https://api.github.com/users/sloria","html_url":"https://github.com/sloria","followers_url":"https://api.github.com/users/sloria/followers","following_url":"https://api.github.com/users/sloria/following{/other_user}","gists_url":"https://api.github.com/users/sloria/gists{/gist_id}","starred_url":"https://api.github.com/users/sloria/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sloria/subscriptions","organizations_url":"https://api.github.com/users/sloria/orgs","repos_url":"https://api.github.com/users/sloria/repos","events_url":"https://api.github.com/users/sloria/events{/privacy}","received_events_url":"https://api.github.com/users/sloria/received_events","type":"User","site_admin":false}],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/8213/commits","review_comments_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/8213/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/8213/comments","statuses_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/statuses/499dc8e85f9918e62b0e8fa99f5412f3dff32cab","head":{"label":"brianjgeiger:feature/node-institution-patch","ref":"feature/node-institution-patch","sha":"499dc8e85f9918e62b0e8fa99f5412f3dff32cab","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},"repo":{"id":26919852,"name":"osf.io","full_name":"brianjgeiger/osf.io","owner":{"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},"private":false,"html_url":"https://github.com/brianjgeiger/osf.io","description":"Facilitating Open Science","fork":true,"url":"https://api.github.com/repos/brianjgeiger/osf.io","forks_url":"https://api.github.com/repos/brianjgeiger/osf.io/forks","keys_url":"https://api.github.com/repos/brianjgeiger/osf.io/keys{/key_id}","collaborators_url":"https://api.github.com/repos/brianjgeiger/osf.io/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/brianjgeiger/osf.io/teams","hooks_url":"https://api.github.com/repos/brianjgeiger/osf.io/hooks","issue_events_url":"https://api.github.com/repos/brianjgeiger/osf.io/issues/events{/number}","events_url":"https://api.github.com/repos/brianjgeiger/osf.io/events","assignees_url":"https://api.github.com/repos/brianjgeiger/osf.io/assignees{/user}","branches_url":"https://api.github.com/repos/brianjgeiger/osf.io/branches{/branch}","tags_url":"https://api.github.com/repos/brianjgeiger/osf.io/tags","blobs_url":"https://api.github.com/repos/brianjgeiger/osf.io/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/brianjgeiger/osf.io/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/brianjgeiger/osf.io/git/refs{/sha}","trees_url":"https://api.github.com/repos/brianjgeiger/osf.io/git/trees{/sha}","statuses_url":"https://api.github.com/repos/brianjgeiger/osf.io/statuses/{sha}","languages_url":"https://api.github.com/repos/brianjgeiger/osf.io/languages","stargazers_url":"https://api.github.com/repos/brianjgeiger/osf.io/stargazers","contributors_url":"https://api.github.com/repos/brianjgeiger/osf.io/contributors","subscribers_url":"https://api.github.com/repos/brianjgeiger/osf.io/subscribers","subscription_url":"https://api.github.com/repos/brianjgeiger/osf.io/subscription","commits_url":"https://api.github.com/repos/brianjgeiger/osf.io/commits{/sha}","git_commits_url":"https://api.github.com/repos/brianjgeiger/osf.io/git/commits{/sha}","comments_url":"https://api.github.com/repos/brianjgeiger/osf.io/comments{/number}","issue_comment_url":"https://api.github.com/repos/brianjgeiger/osf.io/issues/comments{/number}","contents_url":"https://api.github.com/repos/brianjgeiger/osf.io/contents/{+path}","compare_url":"https://api.github.com/repos/brianjgeiger/osf.io/compare/{base}...{head}","merges_url":"https://api.github.com/repos/brianjgeiger/osf.io/merges","archive_url":"https://api.github.com/repos/brianjgeiger/osf.io/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/brianjgeiger/osf.io/downloads","issues_url":"https://api.github.com/repos/brianjgeiger/osf.io/issues{/number}","pulls_url":"https://api.github.com/repos/brianjgeiger/osf.io/pulls{/number}","milestones_url":"https://api.github.com/repos/brianjgeiger/osf.io/milestones{/number}","notifications_url":"https://api.github.com/repos/brianjgeiger/osf.io/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/brianjgeiger/osf.io/labels{/name}","releases_url":"https://api.github.com/repos/brianjgeiger/osf.io/releases{/id}","deployments_url":"https://api.github.com/repos/brianjgeiger/osf.io/deployments","created_at":"2014-11-20T15:59:16Z","updated_at":"2017-12-04T01:47:14Z","pushed_at":"2018-03-11T14:15:55Z","git_url":"git://github.com/brianjgeiger/osf.io.git","ssh_url":"git@github.com:brianjgeiger/osf.io.git","clone_url":"https://github.com/brianjgeiger/osf.io.git","svn_url":"https://github.com/brianjgeiger/osf.io","homepage":"http://osf.io","size":167352,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":4,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":0,"open_issues":4,"watchers":0,"default_branch":"develop"}},"base":{"label":"CenterForOpenScience:develop","ref":"develop","sha":"cd58deb172850faa0dff44b77afdeae99ac04d1c","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":"2018-03-12T13:41:36Z","pushed_at":"2018-03-12T21:19:23Z","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":167694,"stargazers_count":427,"watchers_count":427,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":244,"mirror_url":null,"archived":false,"open_issues_count":223,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":244,"open_issues":223,"watchers":427,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/8213"},"html":{"href":"https://github.com/CenterForOpenScience/osf.io/pull/8213"},"issue":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues/8213"},"comments":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues/8213/comments"},"review_comments":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/8213/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/8213/commits"},"statuses":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/statuses/499dc8e85f9918e62b0e8fa99f5412f3dff32cab"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"brianjgeiger"}}