{"action":"created","comment":{"url":"https://api.github.com/repos/fle-internal/content-curation/pulls/comments/127854438","pull_request_review_id":50476860,"id":127854438,"diff_hunk":"@@ -278,3 +359,157 @@ def _move_node(node, parent=None, sort_order=None, channel_id=None):\n                 n.tags.add(t)\n \n     return node\n+\n+def sync_nodes(request):\n+    logging.debug(\"Entering the sync_nodes endpoint\")\n+\n+    if request.method != 'POST':\n+        return HttpResponseBadRequest(\"Only POST requests are allowed on this endpoint.\")\n+    else:\n+        data = json.loads(request.body)\n+\n+        try:\n+            nodes = data[\"nodes\"]\n+            channel_id = data['channel_id']\n+\n+        except KeyError:\n+            return ObjectDoesNotExist(\"Missing attribute from data: {}\".format(data))\n+\n+        all_nodes = []\n+        with transaction.atomic():\n+            with ContentNode.objects.delay_mptt_updates():\n+                for n in nodes:\n+                    node, _ = _sync_node(ContentNode.objects.get(pk=n), channel_id, sync_attributes=True, sync_tags=True, sync_files=True, sync_assessment_items=True)\n+                    if node.changed:\n+                        node.save()\n+                    all_nodes.append(node)\n+        return HttpResponse(JSONRenderer().render(ContentNodeSerializer(all_nodes, many=True).data))\n+\n+\n+def _sync_node(node, channel_id, sync_attributes=False, sync_tags=False, sync_files=False, sync_assessment_items=False, sync_sort_order=False):\n+    parents_to_check = []\n+    original_node = node.get_original_node()\n+    if original_node.node_id != node.node_id: # Only update if node is not original\n+        logging.info(\"----- Syncing: {} from {}\".format(node.title.encode('utf-8'), original_node.get_channel().name.encode('utf-8')))\n+        if sync_attributes:","path":"contentcuration/contentcuration/view/node_views.py","position":133,"original_position":133,"commit_id":"ab08d5d049fb0848f212b7a0cb4a0b00333814dd","original_commit_id":"ab08d5d049fb0848f212b7a0cb4a0b00333814dd","user":{"login":"aronasorman","id":191955,"avatar_url":"https://avatars0.githubusercontent.com/u/191955?v=4","gravatar_id":"","url":"https://api.github.com/users/aronasorman","html_url":"https://github.com/aronasorman","followers_url":"https://api.github.com/users/aronasorman/followers","following_url":"https://api.github.com/users/aronasorman/following{/other_user}","gists_url":"https://api.github.com/users/aronasorman/gists{/gist_id}","starred_url":"https://api.github.com/users/aronasorman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aronasorman/subscriptions","organizations_url":"https://api.github.com/users/aronasorman/orgs","repos_url":"https://api.github.com/users/aronasorman/repos","events_url":"https://api.github.com/users/aronasorman/events{/privacy}","received_events_url":"https://api.github.com/users/aronasorman/received_events","type":"User","site_admin":false},"body":"Add a description as to what each of these if statements do","created_at":"2017-07-17T23:49:42Z","updated_at":"2017-07-17T23:52:03Z","html_url":"https://github.com/fle-internal/content-curation/pull/331#discussion_r127854438","pull_request_url":"https://api.github.com/repos/fle-internal/content-curation/pulls/331","_links":{"self":{"href":"https://api.github.com/repos/fle-internal/content-curation/pulls/comments/127854438"},"html":{"href":"https://github.com/fle-internal/content-curation/pull/331#discussion_r127854438"},"pull_request":{"href":"https://api.github.com/repos/fle-internal/content-curation/pulls/331"}}},"pull_request":{"url":"https://api.github.com/repos/fle-internal/content-curation/pulls/331","id":124960148,"html_url":"https://github.com/fle-internal/content-curation/pull/331","diff_url":"https://github.com/fle-internal/content-curation/pull/331.diff","patch_url":"https://github.com/fle-internal/content-curation/pull/331.patch","issue_url":"https://api.github.com/repos/fle-internal/content-curation/issues/331","number":331,"state":"open","locked":false,"title":"Sync nodes front-end tools","user":{"login":"jayoshih","id":7447496,"avatar_url":"https://avatars0.githubusercontent.com/u/7447496?v=4","gravatar_id":"","url":"https://api.github.com/users/jayoshih","html_url":"https://github.com/jayoshih","followers_url":"https://api.github.com/users/jayoshih/followers","following_url":"https://api.github.com/users/jayoshih/following{/other_user}","gists_url":"https://api.github.com/users/jayoshih/gists{/gist_id}","starred_url":"https://api.github.com/users/jayoshih/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jayoshih/subscriptions","organizations_url":"https://api.github.com/users/jayoshih/orgs","repos_url":"https://api.github.com/users/jayoshih/repos","events_url":"https://api.github.com/users/jayoshih/events{/privacy}","received_events_url":"https://api.github.com/users/jayoshih/received_events","type":"User","site_admin":false},"body":"","created_at":"2017-06-09T22:19:09Z","updated_at":"2017-07-17T23:52:03Z","closed_at":null,"merged_at":null,"merge_commit_sha":"85e8e2a5ebe430423945a76b2572704d46679adc","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/fle-internal/content-curation/pulls/331/commits","review_comments_url":"https://api.github.com/repos/fle-internal/content-curation/pulls/331/comments","review_comment_url":"https://api.github.com/repos/fle-internal/content-curation/pulls/comments{/number}","comments_url":"https://api.github.com/repos/fle-internal/content-curation/issues/331/comments","statuses_url":"https://api.github.com/repos/fle-internal/content-curation/statuses/ab08d5d049fb0848f212b7a0cb4a0b00333814dd","head":{"label":"jayoshih:sync-nodes","ref":"sync-nodes","sha":"ab08d5d049fb0848f212b7a0cb4a0b00333814dd","user":{"login":"jayoshih","id":7447496,"avatar_url":"https://avatars0.githubusercontent.com/u/7447496?v=4","gravatar_id":"","url":"https://api.github.com/users/jayoshih","html_url":"https://github.com/jayoshih","followers_url":"https://api.github.com/users/jayoshih/followers","following_url":"https://api.github.com/users/jayoshih/following{/other_user}","gists_url":"https://api.github.com/users/jayoshih/gists{/gist_id}","starred_url":"https://api.github.com/users/jayoshih/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jayoshih/subscriptions","organizations_url":"https://api.github.com/users/jayoshih/orgs","repos_url":"https://api.github.com/users/jayoshih/repos","events_url":"https://api.github.com/users/jayoshih/events{/privacy}","received_events_url":"https://api.github.com/users/jayoshih/received_events","type":"User","site_admin":false},"repo":{"id":38459600,"name":"content-curation","full_name":"jayoshih/content-curation","owner":{"login":"jayoshih","id":7447496,"avatar_url":"https://avatars0.githubusercontent.com/u/7447496?v=4","gravatar_id":"","url":"https://api.github.com/users/jayoshih","html_url":"https://github.com/jayoshih","followers_url":"https://api.github.com/users/jayoshih/followers","following_url":"https://api.github.com/users/jayoshih/following{/other_user}","gists_url":"https://api.github.com/users/jayoshih/gists{/gist_id}","starred_url":"https://api.github.com/users/jayoshih/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jayoshih/subscriptions","organizations_url":"https://api.github.com/users/jayoshih/orgs","repos_url":"https://api.github.com/users/jayoshih/repos","events_url":"https://api.github.com/users/jayoshih/events{/privacy}","received_events_url":"https://api.github.com/users/jayoshih/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jayoshih/content-curation","description":null,"fork":true,"url":"https://api.github.com/repos/jayoshih/content-curation","forks_url":"https://api.github.com/repos/jayoshih/content-curation/forks","keys_url":"https://api.github.com/repos/jayoshih/content-curation/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jayoshih/content-curation/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jayoshih/content-curation/teams","hooks_url":"https://api.github.com/repos/jayoshih/content-curation/hooks","issue_events_url":"https://api.github.com/repos/jayoshih/content-curation/issues/events{/number}","events_url":"https://api.github.com/repos/jayoshih/content-curation/events","assignees_url":"https://api.github.com/repos/jayoshih/content-curation/assignees{/user}","branches_url":"https://api.github.com/repos/jayoshih/content-curation/branches{/branch}","tags_url":"https://api.github.com/repos/jayoshih/content-curation/tags","blobs_url":"https://api.github.com/repos/jayoshih/content-curation/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jayoshih/content-curation/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jayoshih/content-curation/git/refs{/sha}","trees_url":"https://api.github.com/repos/jayoshih/content-curation/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jayoshih/content-curation/statuses/{sha}","languages_url":"https://api.github.com/repos/jayoshih/content-curation/languages","stargazers_url":"https://api.github.com/repos/jayoshih/content-curation/stargazers","contributors_url":"https://api.github.com/repos/jayoshih/content-curation/contributors","subscribers_url":"https://api.github.com/repos/jayoshih/content-curation/subscribers","subscription_url":"https://api.github.com/repos/jayoshih/content-curation/subscription","commits_url":"https://api.github.com/repos/jayoshih/content-curation/commits{/sha}","git_commits_url":"https://api.github.com/repos/jayoshih/content-curation/git/commits{/sha}","comments_url":"https://api.github.com/repos/jayoshih/content-curation/comments{/number}","issue_comment_url":"https://api.github.com/repos/jayoshih/content-curation/issues/comments{/number}","contents_url":"https://api.github.com/repos/jayoshih/content-curation/contents/{+path}","compare_url":"https://api.github.com/repos/jayoshih/content-curation/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jayoshih/content-curation/merges","archive_url":"https://api.github.com/repos/jayoshih/content-curation/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jayoshih/content-curation/downloads","issues_url":"https://api.github.com/repos/jayoshih/content-curation/issues{/number}","pulls_url":"https://api.github.com/repos/jayoshih/content-curation/pulls{/number}","milestones_url":"https://api.github.com/repos/jayoshih/content-curation/milestones{/number}","notifications_url":"https://api.github.com/repos/jayoshih/content-curation/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jayoshih/content-curation/labels{/name}","releases_url":"https://api.github.com/repos/jayoshih/content-curation/releases{/id}","deployments_url":"https://api.github.com/repos/jayoshih/content-curation/deployments","created_at":"2015-07-02T22:18:07Z","updated_at":"2016-11-09T20:10:37Z","pushed_at":"2017-07-17T22:19:47Z","git_url":"git://github.com/jayoshih/content-curation.git","ssh_url":"git@github.com:jayoshih/content-curation.git","clone_url":"https://github.com/jayoshih/content-curation.git","svn_url":"https://github.com/jayoshih/content-curation","homepage":null,"size":155512,"stargazers_count":0,"watchers_count":0,"language":"HTML","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":0,"forks":1,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"fle-internal:develop","ref":"develop","sha":"9ceed5a759048e6e4f0f8aa8230b403c29144e5f","user":{"login":"fle-internal","id":6564452,"avatar_url":"https://avatars0.githubusercontent.com/u/6564452?v=4","gravatar_id":"","url":"https://api.github.com/users/fle-internal","html_url":"https://github.com/fle-internal","followers_url":"https://api.github.com/users/fle-internal/followers","following_url":"https://api.github.com/users/fle-internal/following{/other_user}","gists_url":"https://api.github.com/users/fle-internal/gists{/gist_id}","starred_url":"https://api.github.com/users/fle-internal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fle-internal/subscriptions","organizations_url":"https://api.github.com/users/fle-internal/orgs","repos_url":"https://api.github.com/users/fle-internal/repos","events_url":"https://api.github.com/users/fle-internal/events{/privacy}","received_events_url":"https://api.github.com/users/fle-internal/received_events","type":"Organization","site_admin":false},"repo":{"id":35178170,"name":"content-curation","full_name":"fle-internal/content-curation","owner":{"login":"fle-internal","id":6564452,"avatar_url":"https://avatars0.githubusercontent.com/u/6564452?v=4","gravatar_id":"","url":"https://api.github.com/users/fle-internal","html_url":"https://github.com/fle-internal","followers_url":"https://api.github.com/users/fle-internal/followers","following_url":"https://api.github.com/users/fle-internal/following{/other_user}","gists_url":"https://api.github.com/users/fle-internal/gists{/gist_id}","starred_url":"https://api.github.com/users/fle-internal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fle-internal/subscriptions","organizations_url":"https://api.github.com/users/fle-internal/orgs","repos_url":"https://api.github.com/users/fle-internal/repos","events_url":"https://api.github.com/users/fle-internal/events{/privacy}","received_events_url":"https://api.github.com/users/fle-internal/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/fle-internal/content-curation","description":null,"fork":false,"url":"https://api.github.com/repos/fle-internal/content-curation","forks_url":"https://api.github.com/repos/fle-internal/content-curation/forks","keys_url":"https://api.github.com/repos/fle-internal/content-curation/keys{/key_id}","collaborators_url":"https://api.github.com/repos/fle-internal/content-curation/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/fle-internal/content-curation/teams","hooks_url":"https://api.github.com/repos/fle-internal/content-curation/hooks","issue_events_url":"https://api.github.com/repos/fle-internal/content-curation/issues/events{/number}","events_url":"https://api.github.com/repos/fle-internal/content-curation/events","assignees_url":"https://api.github.com/repos/fle-internal/content-curation/assignees{/user}","branches_url":"https://api.github.com/repos/fle-internal/content-curation/branches{/branch}","tags_url":"https://api.github.com/repos/fle-internal/content-curation/tags","blobs_url":"https://api.github.com/repos/fle-internal/content-curation/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/fle-internal/content-curation/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/fle-internal/content-curation/git/refs{/sha}","trees_url":"https://api.github.com/repos/fle-internal/content-curation/git/trees{/sha}","statuses_url":"https://api.github.com/repos/fle-internal/content-curation/statuses/{sha}","languages_url":"https://api.github.com/repos/fle-internal/content-curation/languages","stargazers_url":"https://api.github.com/repos/fle-internal/content-curation/stargazers","contributors_url":"https://api.github.com/repos/fle-internal/content-curation/contributors","subscribers_url":"https://api.github.com/repos/fle-internal/content-curation/subscribers","subscription_url":"https://api.github.com/repos/fle-internal/content-curation/subscription","commits_url":"https://api.github.com/repos/fle-internal/content-curation/commits{/sha}","git_commits_url":"https://api.github.com/repos/fle-internal/content-curation/git/commits{/sha}","comments_url":"https://api.github.com/repos/fle-internal/content-curation/comments{/number}","issue_comment_url":"https://api.github.com/repos/fle-internal/content-curation/issues/comments{/number}","contents_url":"https://api.github.com/repos/fle-internal/content-curation/contents/{+path}","compare_url":"https://api.github.com/repos/fle-internal/content-curation/compare/{base}...{head}","merges_url":"https://api.github.com/repos/fle-internal/content-curation/merges","archive_url":"https://api.github.com/repos/fle-internal/content-curation/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/fle-internal/content-curation/downloads","issues_url":"https://api.github.com/repos/fle-internal/content-curation/issues{/number}","pulls_url":"https://api.github.com/repos/fle-internal/content-curation/pulls{/number}","milestones_url":"https://api.github.com/repos/fle-internal/content-curation/milestones{/number}","notifications_url":"https://api.github.com/repos/fle-internal/content-curation/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/fle-internal/content-curation/labels{/name}","releases_url":"https://api.github.com/repos/fle-internal/content-curation/releases{/id}","deployments_url":"https://api.github.com/repos/fle-internal/content-curation/deployments","created_at":"2015-05-06T19:18:28Z","updated_at":"2017-05-31T21:08:39Z","pushed_at":"2017-07-17T22:19:48Z","git_url":"git://github.com/fle-internal/content-curation.git","ssh_url":"git@github.com:fle-internal/content-curation.git","clone_url":"https://github.com/fle-internal/content-curation.git","svn_url":"https://github.com/fle-internal/content-curation","homepage":null,"size":155240,"stargazers_count":5,"watchers_count":5,"language":"HTML","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":20,"mirror_url":null,"open_issues_count":25,"forks":20,"open_issues":25,"watchers":5,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/fle-internal/content-curation/pulls/331"},"html":{"href":"https://github.com/fle-internal/content-curation/pull/331"},"issue":{"href":"https://api.github.com/repos/fle-internal/content-curation/issues/331"},"comments":{"href":"https://api.github.com/repos/fle-internal/content-curation/issues/331/comments"},"review_comments":{"href":"https://api.github.com/repos/fle-internal/content-curation/pulls/331/comments"},"review_comment":{"href":"https://api.github.com/repos/fle-internal/content-curation/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/fle-internal/content-curation/pulls/331/commits"},"statuses":{"href":"https://api.github.com/repos/fle-internal/content-curation/statuses/ab08d5d049fb0848f212b7a0cb4a0b00333814dd"}}}}
{"actor":{"display_login":"aronasorman"}}