{"action":"created","comment":{"url":"https://api.github.com/repos/universalcore/unicore-cms-django/pulls/comments/29663699","id":29663699,"diff_hunk":"@@ -59,6 +65,39 @@ def emit(self, message):\n         if not self.quiet:\n             self.stdout.write(message)\n \n+    def get_thumbor_image_file(self, host, uuid, use_safe_url=False):\n+        '''\n+        NOTE: To download an image from the Thumbor host we\n+        either need a security key for the particular host,\n+        or the host must allow unsafe urls.\n+        '''\n+        if use_safe_url:\n+            url = thumbor_image_url(uuid)\n+        else:\n+            url = urljoin(host, 'unsafe/%s' % uuid)\n+\n+        response = requests.get(url)\n+        if response.status_code == 200:\n+            return (\n+                ContentFile(response.content),\n+                response.headers['Content-Type'])\n+        return None, None\n+\n+    def set_image_field(self, eg_obj, db_obj, field_name):\n+        uuid = getattr(eg_obj, field_name)\n+        host = getattr(eg_obj, '%s_host' % field_name)\n+        if None in (uuid, host):\n+            return\n+\n+        file_obj, content_type = self.get_thumbor_image_file(host, uuid)","path":"cms/management/commands/import_from_git.py","position":40,"original_position":40,"commit_id":"ac9fdbd2dabbda8f66b0956b1e07b638c22de0e0","original_commit_id":"ac9fdbd2dabbda8f66b0956b1e07b638c22de0e0","user":{"login":"miltontony","id":623417,"avatar_url":"https://avatars.githubusercontent.com/u/623417?v=3","gravatar_id":"","url":"https://api.github.com/users/miltontony","html_url":"https://github.com/miltontony","followers_url":"https://api.github.com/users/miltontony/followers","following_url":"https://api.github.com/users/miltontony/following{/other_user}","gists_url":"https://api.github.com/users/miltontony/gists{/gist_id}","starred_url":"https://api.github.com/users/miltontony/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/miltontony/subscriptions","organizations_url":"https://api.github.com/users/miltontony/orgs","repos_url":"https://api.github.com/users/miltontony/repos","events_url":"https://api.github.com/users/miltontony/events{/privacy}","received_events_url":"https://api.github.com/users/miltontony/received_events","type":"User","site_admin":false},"body":"k. Let's keep this then.","created_at":"2015-05-05T12:30:54Z","updated_at":"2015-05-05T12:30:54Z","html_url":"https://github.com/universalcore/unicore-cms-django/pull/66#discussion_r29663699","pull_request_url":"https://api.github.com/repos/universalcore/unicore-cms-django/pulls/66","_links":{"self":{"href":"https://api.github.com/repos/universalcore/unicore-cms-django/pulls/comments/29663699"},"html":{"href":"https://github.com/universalcore/unicore-cms-django/pull/66#discussion_r29663699"},"pull_request":{"href":"https://api.github.com/repos/universalcore/unicore-cms-django/pulls/66"}}},"pull_request":{"url":"https://api.github.com/repos/universalcore/unicore-cms-django/pulls/66","id":34716155,"html_url":"https://github.com/universalcore/unicore-cms-django/pull/66","diff_url":"https://github.com/universalcore/unicore-cms-django/pull/66.diff","patch_url":"https://github.com/universalcore/unicore-cms-django/pull/66.patch","issue_url":"https://api.github.com/repos/universalcore/unicore-cms-django/issues/66","number":66,"state":"open","locked":false,"title":"set Localisation image fields in import_from_git command","user":{"login":"Rizziepit","id":588701,"avatar_url":"https://avatars.githubusercontent.com/u/588701?v=3","gravatar_id":"","url":"https://api.github.com/users/Rizziepit","html_url":"https://github.com/Rizziepit","followers_url":"https://api.github.com/users/Rizziepit/followers","following_url":"https://api.github.com/users/Rizziepit/following{/other_user}","gists_url":"https://api.github.com/users/Rizziepit/gists{/gist_id}","starred_url":"https://api.github.com/users/Rizziepit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Rizziepit/subscriptions","organizations_url":"https://api.github.com/users/Rizziepit/orgs","repos_url":"https://api.github.com/users/Rizziepit/repos","events_url":"https://api.github.com/users/Rizziepit/events{/privacy}","received_events_url":"https://api.github.com/users/Rizziepit/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-05-05T11:40:31Z","updated_at":"2015-05-05T12:30:54Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4fceed4c4ccda12b11442ea58f3c1de38a7ffe73","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/universalcore/unicore-cms-django/pulls/66/commits","review_comments_url":"https://api.github.com/repos/universalcore/unicore-cms-django/pulls/66/comments","review_comment_url":"https://api.github.com/repos/universalcore/unicore-cms-django/pulls/comments{/number}","comments_url":"https://api.github.com/repos/universalcore/unicore-cms-django/issues/66/comments","statuses_url":"https://api.github.com/repos/universalcore/unicore-cms-django/statuses/ac9fdbd2dabbda8f66b0956b1e07b638c22de0e0","head":{"label":"universalcore:feature/issue-66-set-localisation-image-fields-in-import_from_git-command","ref":"feature/issue-66-set-localisation-image-fields-in-import_from_git-command","sha":"ac9fdbd2dabbda8f66b0956b1e07b638c22de0e0","user":{"login":"universalcore","id":8818658,"avatar_url":"https://avatars.githubusercontent.com/u/8818658?v=3","gravatar_id":"","url":"https://api.github.com/users/universalcore","html_url":"https://github.com/universalcore","followers_url":"https://api.github.com/users/universalcore/followers","following_url":"https://api.github.com/users/universalcore/following{/other_user}","gists_url":"https://api.github.com/users/universalcore/gists{/gist_id}","starred_url":"https://api.github.com/users/universalcore/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/universalcore/subscriptions","organizations_url":"https://api.github.com/users/universalcore/orgs","repos_url":"https://api.github.com/users/universalcore/repos","events_url":"https://api.github.com/users/universalcore/events{/privacy}","received_events_url":"https://api.github.com/users/universalcore/received_events","type":"Organization","site_admin":false},"repo":{"id":23872321,"name":"unicore-cms-django","full_name":"universalcore/unicore-cms-django","owner":{"login":"universalcore","id":8818658,"avatar_url":"https://avatars.githubusercontent.com/u/8818658?v=3","gravatar_id":"","url":"https://api.github.com/users/universalcore","html_url":"https://github.com/universalcore","followers_url":"https://api.github.com/users/universalcore/followers","following_url":"https://api.github.com/users/universalcore/following{/other_user}","gists_url":"https://api.github.com/users/universalcore/gists{/gist_id}","starred_url":"https://api.github.com/users/universalcore/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/universalcore/subscriptions","organizations_url":"https://api.github.com/users/universalcore/orgs","repos_url":"https://api.github.com/users/universalcore/repos","events_url":"https://api.github.com/users/universalcore/events{/privacy}","received_events_url":"https://api.github.com/users/universalcore/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/universalcore/unicore-cms-django","description":"A temporary Django CMS for authoring Unicore-CMS content","fork":false,"url":"https://api.github.com/repos/universalcore/unicore-cms-django","forks_url":"https://api.github.com/repos/universalcore/unicore-cms-django/forks","keys_url":"https://api.github.com/repos/universalcore/unicore-cms-django/keys{/key_id}","collaborators_url":"https://api.github.com/repos/universalcore/unicore-cms-django/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/universalcore/unicore-cms-django/teams","hooks_url":"https://api.github.com/repos/universalcore/unicore-cms-django/hooks","issue_events_url":"https://api.github.com/repos/universalcore/unicore-cms-django/issues/events{/number}","events_url":"https://api.github.com/repos/universalcore/unicore-cms-django/events","assignees_url":"https://api.github.com/repos/universalcore/unicore-cms-django/assignees{/user}","branches_url":"https://api.github.com/repos/universalcore/unicore-cms-django/branches{/branch}","tags_url":"https://api.github.com/repos/universalcore/unicore-cms-django/tags","blobs_url":"https://api.github.com/repos/universalcore/unicore-cms-django/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/universalcore/unicore-cms-django/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/universalcore/unicore-cms-django/git/refs{/sha}","trees_url":"https://api.github.com/repos/universalcore/unicore-cms-django/git/trees{/sha}","statuses_url":"https://api.github.com/repos/universalcore/unicore-cms-django/statuses/{sha}","languages_url":"https://api.github.com/repos/universalcore/unicore-cms-django/languages","stargazers_url":"https://api.github.com/repos/universalcore/unicore-cms-django/stargazers","contributors_url":"https://api.github.com/repos/universalcore/unicore-cms-django/contributors","subscribers_url":"https://api.github.com/repos/universalcore/unicore-cms-django/subscribers","subscription_url":"https://api.github.com/repos/universalcore/unicore-cms-django/subscription","commits_url":"https://api.github.com/repos/universalcore/unicore-cms-django/commits{/sha}","git_commits_url":"https://api.github.com/repos/universalcore/unicore-cms-django/git/commits{/sha}","comments_url":"https://api.github.com/repos/universalcore/unicore-cms-django/comments{/number}","issue_comment_url":"https://api.github.com/repos/universalcore/unicore-cms-django/issues/comments{/number}","contents_url":"https://api.github.com/repos/universalcore/unicore-cms-django/contents/{+path}","compare_url":"https://api.github.com/repos/universalcore/unicore-cms-django/compare/{base}...{head}","merges_url":"https://api.github.com/repos/universalcore/unicore-cms-django/merges","archive_url":"https://api.github.com/repos/universalcore/unicore-cms-django/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/universalcore/unicore-cms-django/downloads","issues_url":"https://api.github.com/repos/universalcore/unicore-cms-django/issues{/number}","pulls_url":"https://api.github.com/repos/universalcore/unicore-cms-django/pulls{/number}","milestones_url":"https://api.github.com/repos/universalcore/unicore-cms-django/milestones{/number}","notifications_url":"https://api.github.com/repos/universalcore/unicore-cms-django/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/universalcore/unicore-cms-django/labels{/name}","releases_url":"https://api.github.com/repos/universalcore/unicore-cms-django/releases{/id}","created_at":"2014-09-10T11:40:54Z","updated_at":"2015-04-28T10:10:33Z","pushed_at":"2015-05-05T11:40:32Z","git_url":"git://github.com/universalcore/unicore-cms-django.git","ssh_url":"git@github.com:universalcore/unicore-cms-django.git","clone_url":"https://github.com/universalcore/unicore-cms-django.git","svn_url":"https://github.com/universalcore/unicore-cms-django","homepage":null,"size":2148,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":3,"forks":0,"open_issues":3,"watchers":1,"default_branch":"develop"}},"base":{"label":"universalcore:develop","ref":"develop","sha":"9d09a4f843ff92593fa120fdc16e78e24b06f59a","user":{"login":"universalcore","id":8818658,"avatar_url":"https://avatars.githubusercontent.com/u/8818658?v=3","gravatar_id":"","url":"https://api.github.com/users/universalcore","html_url":"https://github.com/universalcore","followers_url":"https://api.github.com/users/universalcore/followers","following_url":"https://api.github.com/users/universalcore/following{/other_user}","gists_url":"https://api.github.com/users/universalcore/gists{/gist_id}","starred_url":"https://api.github.com/users/universalcore/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/universalcore/subscriptions","organizations_url":"https://api.github.com/users/universalcore/orgs","repos_url":"https://api.github.com/users/universalcore/repos","events_url":"https://api.github.com/users/universalcore/events{/privacy}","received_events_url":"https://api.github.com/users/universalcore/received_events","type":"Organization","site_admin":false},"repo":{"id":23872321,"name":"unicore-cms-django","full_name":"universalcore/unicore-cms-django","owner":{"login":"universalcore","id":8818658,"avatar_url":"https://avatars.githubusercontent.com/u/8818658?v=3","gravatar_id":"","url":"https://api.github.com/users/universalcore","html_url":"https://github.com/universalcore","followers_url":"https://api.github.com/users/universalcore/followers","following_url":"https://api.github.com/users/universalcore/following{/other_user}","gists_url":"https://api.github.com/users/universalcore/gists{/gist_id}","starred_url":"https://api.github.com/users/universalcore/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/universalcore/subscriptions","organizations_url":"https://api.github.com/users/universalcore/orgs","repos_url":"https://api.github.com/users/universalcore/repos","events_url":"https://api.github.com/users/universalcore/events{/privacy}","received_events_url":"https://api.github.com/users/universalcore/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/universalcore/unicore-cms-django","description":"A temporary Django CMS for authoring Unicore-CMS content","fork":false,"url":"https://api.github.com/repos/universalcore/unicore-cms-django","forks_url":"https://api.github.com/repos/universalcore/unicore-cms-django/forks","keys_url":"https://api.github.com/repos/universalcore/unicore-cms-django/keys{/key_id}","collaborators_url":"https://api.github.com/repos/universalcore/unicore-cms-django/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/universalcore/unicore-cms-django/teams","hooks_url":"https://api.github.com/repos/universalcore/unicore-cms-django/hooks","issue_events_url":"https://api.github.com/repos/universalcore/unicore-cms-django/issues/events{/number}","events_url":"https://api.github.com/repos/universalcore/unicore-cms-django/events","assignees_url":"https://api.github.com/repos/universalcore/unicore-cms-django/assignees{/user}","branches_url":"https://api.github.com/repos/universalcore/unicore-cms-django/branches{/branch}","tags_url":"https://api.github.com/repos/universalcore/unicore-cms-django/tags","blobs_url":"https://api.github.com/repos/universalcore/unicore-cms-django/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/universalcore/unicore-cms-django/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/universalcore/unicore-cms-django/git/refs{/sha}","trees_url":"https://api.github.com/repos/universalcore/unicore-cms-django/git/trees{/sha}","statuses_url":"https://api.github.com/repos/universalcore/unicore-cms-django/statuses/{sha}","languages_url":"https://api.github.com/repos/universalcore/unicore-cms-django/languages","stargazers_url":"https://api.github.com/repos/universalcore/unicore-cms-django/stargazers","contributors_url":"https://api.github.com/repos/universalcore/unicore-cms-django/contributors","subscribers_url":"https://api.github.com/repos/universalcore/unicore-cms-django/subscribers","subscription_url":"https://api.github.com/repos/universalcore/unicore-cms-django/subscription","commits_url":"https://api.github.com/repos/universalcore/unicore-cms-django/commits{/sha}","git_commits_url":"https://api.github.com/repos/universalcore/unicore-cms-django/git/commits{/sha}","comments_url":"https://api.github.com/repos/universalcore/unicore-cms-django/comments{/number}","issue_comment_url":"https://api.github.com/repos/universalcore/unicore-cms-django/issues/comments{/number}","contents_url":"https://api.github.com/repos/universalcore/unicore-cms-django/contents/{+path}","compare_url":"https://api.github.com/repos/universalcore/unicore-cms-django/compare/{base}...{head}","merges_url":"https://api.github.com/repos/universalcore/unicore-cms-django/merges","archive_url":"https://api.github.com/repos/universalcore/unicore-cms-django/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/universalcore/unicore-cms-django/downloads","issues_url":"https://api.github.com/repos/universalcore/unicore-cms-django/issues{/number}","pulls_url":"https://api.github.com/repos/universalcore/unicore-cms-django/pulls{/number}","milestones_url":"https://api.github.com/repos/universalcore/unicore-cms-django/milestones{/number}","notifications_url":"https://api.github.com/repos/universalcore/unicore-cms-django/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/universalcore/unicore-cms-django/labels{/name}","releases_url":"https://api.github.com/repos/universalcore/unicore-cms-django/releases{/id}","created_at":"2014-09-10T11:40:54Z","updated_at":"2015-04-28T10:10:33Z","pushed_at":"2015-05-05T11:40:32Z","git_url":"git://github.com/universalcore/unicore-cms-django.git","ssh_url":"git@github.com:universalcore/unicore-cms-django.git","clone_url":"https://github.com/universalcore/unicore-cms-django.git","svn_url":"https://github.com/universalcore/unicore-cms-django","homepage":null,"size":2148,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":3,"forks":0,"open_issues":3,"watchers":1,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/universalcore/unicore-cms-django/pulls/66"},"html":{"href":"https://github.com/universalcore/unicore-cms-django/pull/66"},"issue":{"href":"https://api.github.com/repos/universalcore/unicore-cms-django/issues/66"},"comments":{"href":"https://api.github.com/repos/universalcore/unicore-cms-django/issues/66/comments"},"review_comments":{"href":"https://api.github.com/repos/universalcore/unicore-cms-django/pulls/66/comments"},"review_comment":{"href":"https://api.github.com/repos/universalcore/unicore-cms-django/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/universalcore/unicore-cms-django/pulls/66/commits"},"statuses":{"href":"https://api.github.com/repos/universalcore/unicore-cms-django/statuses/ac9fdbd2dabbda8f66b0956b1e07b638c22de0e0"}}}}