{"action":"created","comment":{"url":"https://api.github.com/repos/edx-solutions/xblock-drag-and-drop-v2/pulls/comments/74210508","id":74210508,"diff_hunk":"@@ -5,3 +5,135 @@\n # Make '_' a no-op so we can scrape strings\n def _(text):\n     return text\n+\n+\n+class Constants(object):\n+    ALLOWED_ZONE_ALIGNMENT = ['left', 'right', 'center']\n+    DEFAULT_ZONE_ALIGNMENT = 'center'\n+\n+\n+class StateMigration(object):\n+    \"\"\"\n+    Helper class to apply zone data and item state migrations\n+    \"\"\"\n+\n+    @classmethod\n+    def _apply_migration(cls, obj, migrations):\n+        \"\"\"\n+        Applies migrations sequentially to a copy of an `obj`, to avoid updating actual data\n+        \"\"\"\n+        tmp = obj.copy()\n+        for method in migrations:\n+            tmp = method(tmp)\n+\n+        return tmp\n+\n+    @classmethod\n+    def apply_zone_migrations(cls, zone):\n+        \"\"\"\n+        Applies zone migrations\n+        \"\"\"\n+        migrations = (cls._zone_v1_to_v2, cls._zone_v2_to_v2p1)\n+\n+        return cls._apply_migration(zone, migrations)\n+\n+    @classmethod\n+    def apply_item_state_migrations(cls, item_state):\n+        \"\"\"\n+        Applies item_state migrations\n+        \"\"\"\n+        migrations = (cls._item_state_v1_to_v1p5, cls._item_state_v1p5_to_v2, cls._item_state_v1p5_to_v2p1)\n+\n+        return cls._apply_migration(item_state, migrations)\n+\n+    @classmethod\n+    def _zone_v1_to_v2(cls, zone):\n+        \"\"\"\n+        Migrates zone data from v1.0 format to v2.0 format.\n+\n+        Changes:\n+        * v1 used zone \"title\" as UID, while v2 have \"uid\" property\n+        * \"id\" and \"index\" properties are no longer used\n+\n+        In: {'id': 1, 'index': 2, 'title': \"Zone\", ...}\n+        Out: {'uid': \"Zone\", ...}\n+        \"\"\"\n+        if \"uid\" not in zone:\n+            zone[\"uid\"] = zone.get(\"title\")\n+        zone.pop(\"id\", None)\n+        zone.pop(\"index\", None)\n+\n+        return zone\n+\n+    @classmethod\n+    def _zone_v2_to_v2p1(cls, zone):\n+        \"\"\"\n+        Migrates zone data from v2.0 to v2.5","path":"drag_and_drop_v2/utils.py","position":67,"original_position":67,"commit_id":"37683586acb41447d613e2a5a7aeb65589cf22a7","original_commit_id":"37683586acb41447d613e2a5a7aeb65589cf22a7","user":{"login":"itsjeyd","id":961441,"avatar_url":"https://avatars.githubusercontent.com/u/961441?v=3","gravatar_id":"","url":"https://api.github.com/users/itsjeyd","html_url":"https://github.com/itsjeyd","followers_url":"https://api.github.com/users/itsjeyd/followers","following_url":"https://api.github.com/users/itsjeyd/following{/other_user}","gists_url":"https://api.github.com/users/itsjeyd/gists{/gist_id}","starred_url":"https://api.github.com/users/itsjeyd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/itsjeyd/subscriptions","organizations_url":"https://api.github.com/users/itsjeyd/orgs","repos_url":"https://api.github.com/users/itsjeyd/repos","events_url":"https://api.github.com/users/itsjeyd/events{/privacy}","received_events_url":"https://api.github.com/users/itsjeyd/received_events","type":"User","site_admin":false},"body":"@e-kolpakov I think this should be `v2.0` to `v.2.1`. Same comment applies to the docstring of `_item_state_v1p5_to_v2p1` below.","created_at":"2016-08-10T09:11:39Z","updated_at":"2016-08-10T09:11:39Z","html_url":"https://github.com/edx-solutions/xblock-drag-and-drop-v2/pull/92#discussion_r74210508","pull_request_url":"https://api.github.com/repos/edx-solutions/xblock-drag-and-drop-v2/pulls/92","_links":{"self":{"href":"https://api.github.com/repos/edx-solutions/xblock-drag-and-drop-v2/pulls/comments/74210508"},"html":{"href":"https://github.com/edx-solutions/xblock-drag-and-drop-v2/pull/92#discussion_r74210508"},"pull_request":{"href":"https://api.github.com/repos/edx-solutions/xblock-drag-and-drop-v2/pulls/92"}}},"pull_request":{"url":"https://api.github.com/repos/edx-solutions/xblock-drag-and-drop-v2/pulls/92","id":80642969,"html_url":"https://github.com/edx-solutions/xblock-drag-and-drop-v2/pull/92","diff_url":"https://github.com/edx-solutions/xblock-drag-and-drop-v2/pull/92.diff","patch_url":"https://github.com/edx-solutions/xblock-drag-and-drop-v2/pull/92.patch","issue_url":"https://api.github.com/repos/edx-solutions/xblock-drag-and-drop-v2/issues/92","number":92,"state":"open","locked":false,"title":"(WIP) Prevent overlapping drop placements","user":{"login":"e-kolpakov","id":3330048,"avatar_url":"https://avatars.githubusercontent.com/u/3330048?v=3","gravatar_id":"","url":"https://api.github.com/users/e-kolpakov","html_url":"https://github.com/e-kolpakov","followers_url":"https://api.github.com/users/e-kolpakov/followers","following_url":"https://api.github.com/users/e-kolpakov/following{/other_user}","gists_url":"https://api.github.com/users/e-kolpakov/gists{/gist_id}","starred_url":"https://api.github.com/users/e-kolpakov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/e-kolpakov/subscriptions","organizations_url":"https://api.github.com/users/e-kolpakov/orgs","repos_url":"https://api.github.com/users/e-kolpakov/repos","events_url":"https://api.github.com/users/e-kolpakov/events{/privacy}","received_events_url":"https://api.github.com/users/e-kolpakov/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-08-09T15:35:00Z","updated_at":"2016-08-10T09:11:39Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8710313ef941d52833354758b1eff2e31f85d908","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/edx-solutions/xblock-drag-and-drop-v2/pulls/92/commits","review_comments_url":"https://api.github.com/repos/edx-solutions/xblock-drag-and-drop-v2/pulls/92/comments","review_comment_url":"https://api.github.com/repos/edx-solutions/xblock-drag-and-drop-v2/pulls/comments{/number}","comments_url":"https://api.github.com/repos/edx-solutions/xblock-drag-and-drop-v2/issues/92/comments","statuses_url":"https://api.github.com/repos/edx-solutions/xblock-drag-and-drop-v2/statuses/37683586acb41447d613e2a5a7aeb65589cf22a7","head":{"label":"open-craft:ekolpakov/non-overlapping-placement","ref":"ekolpakov/non-overlapping-placement","sha":"37683586acb41447d613e2a5a7aeb65589cf22a7","user":{"login":"open-craft","id":7414786,"avatar_url":"https://avatars.githubusercontent.com/u/7414786?v=3","gravatar_id":"","url":"https://api.github.com/users/open-craft","html_url":"https://github.com/open-craft","followers_url":"https://api.github.com/users/open-craft/followers","following_url":"https://api.github.com/users/open-craft/following{/other_user}","gists_url":"https://api.github.com/users/open-craft/gists{/gist_id}","starred_url":"https://api.github.com/users/open-craft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/open-craft/subscriptions","organizations_url":"https://api.github.com/users/open-craft/orgs","repos_url":"https://api.github.com/users/open-craft/repos","events_url":"https://api.github.com/users/open-craft/events{/privacy}","received_events_url":"https://api.github.com/users/open-craft/received_events","type":"Organization","site_admin":false},"repo":{"id":24362875,"name":"xblock-drag-and-drop-v2","full_name":"open-craft/xblock-drag-and-drop-v2","owner":{"login":"open-craft","id":7414786,"avatar_url":"https://avatars.githubusercontent.com/u/7414786?v=3","gravatar_id":"","url":"https://api.github.com/users/open-craft","html_url":"https://github.com/open-craft","followers_url":"https://api.github.com/users/open-craft/followers","following_url":"https://api.github.com/users/open-craft/following{/other_user}","gists_url":"https://api.github.com/users/open-craft/gists{/gist_id}","starred_url":"https://api.github.com/users/open-craft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/open-craft/subscriptions","organizations_url":"https://api.github.com/users/open-craft/orgs","repos_url":"https://api.github.com/users/open-craft/repos","events_url":"https://api.github.com/users/open-craft/events{/privacy}","received_events_url":"https://api.github.com/users/open-craft/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/open-craft/xblock-drag-and-drop-v2","description":"Drag and Drop v2 XBlock","fork":true,"url":"https://api.github.com/repos/open-craft/xblock-drag-and-drop-v2","forks_url":"https://api.github.com/repos/open-craft/xblock-drag-and-drop-v2/forks","keys_url":"https://api.github.com/repos/open-craft/xblock-drag-and-drop-v2/keys{/key_id}","collaborators_url":"https://api.github.com/repos/open-craft/xblock-drag-and-drop-v2/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/open-craft/xblock-drag-and-drop-v2/teams","hooks_url":"https://api.github.com/repos/open-craft/xblock-drag-and-drop-v2/hooks","issue_events_url":"https://api.github.com/repos/open-craft/xblock-drag-and-drop-v2/issues/events{/number}","events_url":"https://api.github.com/repos/open-craft/xblock-drag-and-drop-v2/events","assignees_url":"https://api.github.com/repos/open-craft/xblock-drag-and-drop-v2/assignees{/user}","branches_url":"https://api.github.com/repos/open-craft/xblock-drag-and-drop-v2/branches{/branch}","tags_url":"https://api.github.com/repos/open-craft/xblock-drag-and-drop-v2/tags","blobs_url":"https://api.github.com/repos/open-craft/xblock-drag-and-drop-v2/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/open-craft/xblock-drag-and-drop-v2/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/open-craft/xblock-drag-and-drop-v2/git/refs{/sha}","trees_url":"https://api.github.com/repos/open-craft/xblock-drag-and-drop-v2/git/trees{/sha}","statuses_url":"https://api.github.com/repos/open-craft/xblock-drag-and-drop-v2/statuses/{sha}","languages_url":"https://api.github.com/repos/open-craft/xblock-drag-and-drop-v2/languages","stargazers_url":"https://api.github.com/repos/open-craft/xblock-drag-and-drop-v2/stargazers","contributors_url":"https://api.github.com/repos/open-craft/xblock-drag-and-drop-v2/contributors","subscribers_url":"https://api.github.com/repos/open-craft/xblock-drag-and-drop-v2/subscribers","subscription_url":"https://api.github.com/repos/open-craft/xblock-drag-and-drop-v2/subscription","commits_url":"https://api.github.com/repos/open-craft/xblock-drag-and-drop-v2/commits{/sha}","git_commits_url":"https://api.github.com/repos/open-craft/xblock-drag-and-drop-v2/git/commits{/sha}","comments_url":"https://api.github.com/repos/open-craft/xblock-drag-and-drop-v2/comments{/number}","issue_comment_url":"https://api.github.com/repos/open-craft/xblock-drag-and-drop-v2/issues/comments{/number}","contents_url":"https://api.github.com/repos/open-craft/xblock-drag-and-drop-v2/contents/{+path}","compare_url":"https://api.github.com/repos/open-craft/xblock-drag-and-drop-v2/compare/{base}...{head}","merges_url":"https://api.github.com/repos/open-craft/xblock-drag-and-drop-v2/merges","archive_url":"https://api.github.com/repos/open-craft/xblock-drag-and-drop-v2/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/open-craft/xblock-drag-and-drop-v2/downloads","issues_url":"https://api.github.com/repos/open-craft/xblock-drag-and-drop-v2/issues{/number}","pulls_url":"https://api.github.com/repos/open-craft/xblock-drag-and-drop-v2/pulls{/number}","milestones_url":"https://api.github.com/repos/open-craft/xblock-drag-and-drop-v2/milestones{/number}","notifications_url":"https://api.github.com/repos/open-craft/xblock-drag-and-drop-v2/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/open-craft/xblock-drag-and-drop-v2/labels{/name}","releases_url":"https://api.github.com/repos/open-craft/xblock-drag-and-drop-v2/releases{/id}","deployments_url":"https://api.github.com/repos/open-craft/xblock-drag-and-drop-v2/deployments","created_at":"2014-09-23T08:23:37Z","updated_at":"2015-06-10T12:19:02Z","pushed_at":"2016-08-10T05:44:08Z","git_url":"git://github.com/open-craft/xblock-drag-and-drop-v2.git","ssh_url":"git@github.com:open-craft/xblock-drag-and-drop-v2.git","clone_url":"https://github.com/open-craft/xblock-drag-and-drop-v2.git","svn_url":"https://github.com/open-craft/xblock-drag-and-drop-v2","homepage":"","size":1552,"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":"edx-solutions:master","ref":"master","sha":"2ad8a2cbbd256f3a7e3e2abd8ccf1294ae6cda75","user":{"login":"edx-solutions","id":6585054,"avatar_url":"https://avatars.githubusercontent.com/u/6585054?v=3","gravatar_id":"","url":"https://api.github.com/users/edx-solutions","html_url":"https://github.com/edx-solutions","followers_url":"https://api.github.com/users/edx-solutions/followers","following_url":"https://api.github.com/users/edx-solutions/following{/other_user}","gists_url":"https://api.github.com/users/edx-solutions/gists{/gist_id}","starred_url":"https://api.github.com/users/edx-solutions/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edx-solutions/subscriptions","organizations_url":"https://api.github.com/users/edx-solutions/orgs","repos_url":"https://api.github.com/users/edx-solutions/repos","events_url":"https://api.github.com/users/edx-solutions/events{/privacy}","received_events_url":"https://api.github.com/users/edx-solutions/received_events","type":"Organization","site_admin":false},"repo":{"id":21356168,"name":"xblock-drag-and-drop-v2","full_name":"edx-solutions/xblock-drag-and-drop-v2","owner":{"login":"edx-solutions","id":6585054,"avatar_url":"https://avatars.githubusercontent.com/u/6585054?v=3","gravatar_id":"","url":"https://api.github.com/users/edx-solutions","html_url":"https://github.com/edx-solutions","followers_url":"https://api.github.com/users/edx-solutions/followers","following_url":"https://api.github.com/users/edx-solutions/following{/other_user}","gists_url":"https://api.github.com/users/edx-solutions/gists{/gist_id}","starred_url":"https://api.github.com/users/edx-solutions/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edx-solutions/subscriptions","organizations_url":"https://api.github.com/users/edx-solutions/orgs","repos_url":"https://api.github.com/users/edx-solutions/repos","events_url":"https://api.github.com/users/edx-solutions/events{/privacy}","received_events_url":"https://api.github.com/users/edx-solutions/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/edx-solutions/xblock-drag-and-drop-v2","description":"","fork":false,"url":"https://api.github.com/repos/edx-solutions/xblock-drag-and-drop-v2","forks_url":"https://api.github.com/repos/edx-solutions/xblock-drag-and-drop-v2/forks","keys_url":"https://api.github.com/repos/edx-solutions/xblock-drag-and-drop-v2/keys{/key_id}","collaborators_url":"https://api.github.com/repos/edx-solutions/xblock-drag-and-drop-v2/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/edx-solutions/xblock-drag-and-drop-v2/teams","hooks_url":"https://api.github.com/repos/edx-solutions/xblock-drag-and-drop-v2/hooks","issue_events_url":"https://api.github.com/repos/edx-solutions/xblock-drag-and-drop-v2/issues/events{/number}","events_url":"https://api.github.com/repos/edx-solutions/xblock-drag-and-drop-v2/events","assignees_url":"https://api.github.com/repos/edx-solutions/xblock-drag-and-drop-v2/assignees{/user}","branches_url":"https://api.github.com/repos/edx-solutions/xblock-drag-and-drop-v2/branches{/branch}","tags_url":"https://api.github.com/repos/edx-solutions/xblock-drag-and-drop-v2/tags","blobs_url":"https://api.github.com/repos/edx-solutions/xblock-drag-and-drop-v2/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/edx-solutions/xblock-drag-and-drop-v2/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/edx-solutions/xblock-drag-and-drop-v2/git/refs{/sha}","trees_url":"https://api.github.com/repos/edx-solutions/xblock-drag-and-drop-v2/git/trees{/sha}","statuses_url":"https://api.github.com/repos/edx-solutions/xblock-drag-and-drop-v2/statuses/{sha}","languages_url":"https://api.github.com/repos/edx-solutions/xblock-drag-and-drop-v2/languages","stargazers_url":"https://api.github.com/repos/edx-solutions/xblock-drag-and-drop-v2/stargazers","contributors_url":"https://api.github.com/repos/edx-solutions/xblock-drag-and-drop-v2/contributors","subscribers_url":"https://api.github.com/repos/edx-solutions/xblock-drag-and-drop-v2/subscribers","subscription_url":"https://api.github.com/repos/edx-solutions/xblock-drag-and-drop-v2/subscription","commits_url":"https://api.github.com/repos/edx-solutions/xblock-drag-and-drop-v2/commits{/sha}","git_commits_url":"https://api.github.com/repos/edx-solutions/xblock-drag-and-drop-v2/git/commits{/sha}","comments_url":"https://api.github.com/repos/edx-solutions/xblock-drag-and-drop-v2/comments{/number}","issue_comment_url":"https://api.github.com/repos/edx-solutions/xblock-drag-and-drop-v2/issues/comments{/number}","contents_url":"https://api.github.com/repos/edx-solutions/xblock-drag-and-drop-v2/contents/{+path}","compare_url":"https://api.github.com/repos/edx-solutions/xblock-drag-and-drop-v2/compare/{base}...{head}","merges_url":"https://api.github.com/repos/edx-solutions/xblock-drag-and-drop-v2/merges","archive_url":"https://api.github.com/repos/edx-solutions/xblock-drag-and-drop-v2/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/edx-solutions/xblock-drag-and-drop-v2/downloads","issues_url":"https://api.github.com/repos/edx-solutions/xblock-drag-and-drop-v2/issues{/number}","pulls_url":"https://api.github.com/repos/edx-solutions/xblock-drag-and-drop-v2/pulls{/number}","milestones_url":"https://api.github.com/repos/edx-solutions/xblock-drag-and-drop-v2/milestones{/number}","notifications_url":"https://api.github.com/repos/edx-solutions/xblock-drag-and-drop-v2/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/edx-solutions/xblock-drag-and-drop-v2/labels{/name}","releases_url":"https://api.github.com/repos/edx-solutions/xblock-drag-and-drop-v2/releases{/id}","deployments_url":"https://api.github.com/repos/edx-solutions/xblock-drag-and-drop-v2/deployments","created_at":"2014-06-30T15:30:30Z","updated_at":"2016-07-14T10:19:16Z","pushed_at":"2016-08-10T05:44:08Z","git_url":"git://github.com/edx-solutions/xblock-drag-and-drop-v2.git","ssh_url":"git@github.com:edx-solutions/xblock-drag-and-drop-v2.git","clone_url":"https://github.com/edx-solutions/xblock-drag-and-drop-v2.git","svn_url":"https://github.com/edx-solutions/xblock-drag-and-drop-v2","homepage":null,"size":3141,"stargazers_count":5,"watchers_count":5,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":12,"mirror_url":null,"open_issues_count":7,"forks":12,"open_issues":7,"watchers":5,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/edx-solutions/xblock-drag-and-drop-v2/pulls/92"},"html":{"href":"https://github.com/edx-solutions/xblock-drag-and-drop-v2/pull/92"},"issue":{"href":"https://api.github.com/repos/edx-solutions/xblock-drag-and-drop-v2/issues/92"},"comments":{"href":"https://api.github.com/repos/edx-solutions/xblock-drag-and-drop-v2/issues/92/comments"},"review_comments":{"href":"https://api.github.com/repos/edx-solutions/xblock-drag-and-drop-v2/pulls/92/comments"},"review_comment":{"href":"https://api.github.com/repos/edx-solutions/xblock-drag-and-drop-v2/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/edx-solutions/xblock-drag-and-drop-v2/pulls/92/commits"},"statuses":{"href":"https://api.github.com/repos/edx-solutions/xblock-drag-and-drop-v2/statuses/37683586acb41447d613e2a5a7aeb65589cf22a7"}}}}
{"actor":{"display_login":"itsjeyd"}}