{"action":"created","comment":{"url":"https://api.github.com/repos/incuna/feincms-extensions/pulls/comments/26057160","id":26057160,"diff_hunk":"@@ -0,0 +1,47 @@\n+from feincms.content.medialibrary.models import MediaFileContent\n+from feincms.content.richtext.models import RichTextContent\n+from feincms.content.section.models import SectionContent\n+\n+\n+class JsonRichTextContent(RichTextContent):\n+    class Meta(RichTextContent.Meta):\n+        abstract = True\n+\n+    def json(self, **kwargs):\n+        \"\"\"Return a json serializable dictionary containing the content.\"\"\"\n+        return {'html': self.text}\n+\n+\n+def mediafile_data(mediafile):\n+    \"\"\"Return json serializable data for the mediafile.\"\"\"\n+    if mediafile is None:\n+        return None\n+    return {\n+        'url': mediafile.file.url,\n+        'type': mediafile.type,\n+        'created': mediafile.created,\n+        'copyright': mediafile.copyright,\n+        'file_size': mediafile.file_size,\n+    }\n+\n+\n+class JsonSectionContent(SectionContent):\n+    class Meta(SectionContent.Meta):\n+        abstract = True\n+\n+    def json(self, **kwargs):\n+        \"\"\"Return a json serializable dictionary containing the content.\"\"\"\n+        return {\n+            'title': self.title,\n+            'html': self.richtext,\n+            'mediafile': mediafile_data(self.mediafile),\n+        }\n+\n+\n+class JsonMediaFileContent(MediaFileContent):\n+    class Meta(MediaFileContent.Meta):\n+        abstract = True\n+\n+    def json(self, **kwargs):\n+        \"\"\"Return a json serializable dictionary containing the content.\"\"\"\n+        return {'mediafile': mediafile_data(self.mediafile)}","path":"feincms_extensions/content_types.py","position":47,"original_position":47,"commit_id":"d2eac598f7d3da3d1b65af43374ec9b5fe04a3d4","original_commit_id":"d2eac598f7d3da3d1b65af43374ec9b5fe04a3d4","user":{"login":"Ian-Foote","id":1843202,"avatar_url":"https://avatars.githubusercontent.com/u/1843202?v=3","gravatar_id":"","url":"https://api.github.com/users/Ian-Foote","html_url":"https://github.com/Ian-Foote","followers_url":"https://api.github.com/users/Ian-Foote/followers","following_url":"https://api.github.com/users/Ian-Foote/following{/other_user}","gists_url":"https://api.github.com/users/Ian-Foote/gists{/gist_id}","starred_url":"https://api.github.com/users/Ian-Foote/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Ian-Foote/subscriptions","organizations_url":"https://api.github.com/users/Ian-Foote/orgs","repos_url":"https://api.github.com/users/Ian-Foote/repos","events_url":"https://api.github.com/users/Ian-Foote/events{/privacy}","received_events_url":"https://api.github.com/users/Ian-Foote/received_events","type":"User","site_admin":false},"body":"I could do that. I thought the consistency with `JsonSectionContent` might be useful, but I'm not strongly attached to that position.","created_at":"2015-03-09T17:36:04Z","updated_at":"2015-03-09T17:36:04Z","html_url":"https://github.com/incuna/feincms-extensions/pull/11#discussion_r26057160","pull_request_url":"https://api.github.com/repos/incuna/feincms-extensions/pulls/11","_links":{"self":{"href":"https://api.github.com/repos/incuna/feincms-extensions/pulls/comments/26057160"},"html":{"href":"https://github.com/incuna/feincms-extensions/pull/11#discussion_r26057160"},"pull_request":{"href":"https://api.github.com/repos/incuna/feincms-extensions/pulls/11"}}},"pull_request":{"url":"https://api.github.com/repos/incuna/feincms-extensions/pulls/11","id":30632613,"html_url":"https://github.com/incuna/feincms-extensions/pull/11","diff_url":"https://github.com/incuna/feincms-extensions/pull/11.diff","patch_url":"https://github.com/incuna/feincms-extensions/pull/11.patch","issue_url":"https://api.github.com/repos/incuna/feincms-extensions/issues/11","number":11,"state":"open","locked":false,"title":"Add `render_json` extension","user":{"login":"Ian-Foote","id":1843202,"avatar_url":"https://avatars.githubusercontent.com/u/1843202?v=3","gravatar_id":"","url":"https://api.github.com/users/Ian-Foote","html_url":"https://github.com/Ian-Foote","followers_url":"https://api.github.com/users/Ian-Foote/followers","following_url":"https://api.github.com/users/Ian-Foote/following{/other_user}","gists_url":"https://api.github.com/users/Ian-Foote/gists{/gist_id}","starred_url":"https://api.github.com/users/Ian-Foote/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Ian-Foote/subscriptions","organizations_url":"https://api.github.com/users/Ian-Foote/orgs","repos_url":"https://api.github.com/users/Ian-Foote/repos","events_url":"https://api.github.com/users/Ian-Foote/events{/privacy}","received_events_url":"https://api.github.com/users/Ian-Foote/received_events","type":"User","site_admin":false},"body":null,"created_at":"2015-03-06T09:58:00Z","updated_at":"2015-03-09T17:36:04Z","closed_at":null,"merged_at":null,"merge_commit_sha":"69cc9e0e683faf5d0a52e3ace550e157af621dd9","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/incuna/feincms-extensions/pulls/11/commits","review_comments_url":"https://api.github.com/repos/incuna/feincms-extensions/pulls/11/comments","review_comment_url":"https://api.github.com/repos/incuna/feincms-extensions/pulls/comments{/number}","comments_url":"https://api.github.com/repos/incuna/feincms-extensions/issues/11/comments","statuses_url":"https://api.github.com/repos/incuna/feincms-extensions/statuses/d2eac598f7d3da3d1b65af43374ec9b5fe04a3d4","head":{"label":"incuna:json-regions","ref":"json-regions","sha":"d2eac598f7d3da3d1b65af43374ec9b5fe04a3d4","user":{"login":"incuna","id":55510,"avatar_url":"https://avatars.githubusercontent.com/u/55510?v=3","gravatar_id":"","url":"https://api.github.com/users/incuna","html_url":"https://github.com/incuna","followers_url":"https://api.github.com/users/incuna/followers","following_url":"https://api.github.com/users/incuna/following{/other_user}","gists_url":"https://api.github.com/users/incuna/gists{/gist_id}","starred_url":"https://api.github.com/users/incuna/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/incuna/subscriptions","organizations_url":"https://api.github.com/users/incuna/orgs","repos_url":"https://api.github.com/users/incuna/repos","events_url":"https://api.github.com/users/incuna/events{/privacy}","received_events_url":"https://api.github.com/users/incuna/received_events","type":"Organization","site_admin":false},"repo":{"id":20558038,"name":"feincms-extensions","full_name":"incuna/feincms-extensions","owner":{"login":"incuna","id":55510,"avatar_url":"https://avatars.githubusercontent.com/u/55510?v=3","gravatar_id":"","url":"https://api.github.com/users/incuna","html_url":"https://github.com/incuna","followers_url":"https://api.github.com/users/incuna/followers","following_url":"https://api.github.com/users/incuna/following{/other_user}","gists_url":"https://api.github.com/users/incuna/gists{/gist_id}","starred_url":"https://api.github.com/users/incuna/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/incuna/subscriptions","organizations_url":"https://api.github.com/users/incuna/orgs","repos_url":"https://api.github.com/users/incuna/repos","events_url":"https://api.github.com/users/incuna/events{/privacy}","received_events_url":"https://api.github.com/users/incuna/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/incuna/feincms-extensions","description":"","fork":false,"url":"https://api.github.com/repos/incuna/feincms-extensions","forks_url":"https://api.github.com/repos/incuna/feincms-extensions/forks","keys_url":"https://api.github.com/repos/incuna/feincms-extensions/keys{/key_id}","collaborators_url":"https://api.github.com/repos/incuna/feincms-extensions/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/incuna/feincms-extensions/teams","hooks_url":"https://api.github.com/repos/incuna/feincms-extensions/hooks","issue_events_url":"https://api.github.com/repos/incuna/feincms-extensions/issues/events{/number}","events_url":"https://api.github.com/repos/incuna/feincms-extensions/events","assignees_url":"https://api.github.com/repos/incuna/feincms-extensions/assignees{/user}","branches_url":"https://api.github.com/repos/incuna/feincms-extensions/branches{/branch}","tags_url":"https://api.github.com/repos/incuna/feincms-extensions/tags","blobs_url":"https://api.github.com/repos/incuna/feincms-extensions/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/incuna/feincms-extensions/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/incuna/feincms-extensions/git/refs{/sha}","trees_url":"https://api.github.com/repos/incuna/feincms-extensions/git/trees{/sha}","statuses_url":"https://api.github.com/repos/incuna/feincms-extensions/statuses/{sha}","languages_url":"https://api.github.com/repos/incuna/feincms-extensions/languages","stargazers_url":"https://api.github.com/repos/incuna/feincms-extensions/stargazers","contributors_url":"https://api.github.com/repos/incuna/feincms-extensions/contributors","subscribers_url":"https://api.github.com/repos/incuna/feincms-extensions/subscribers","subscription_url":"https://api.github.com/repos/incuna/feincms-extensions/subscription","commits_url":"https://api.github.com/repos/incuna/feincms-extensions/commits{/sha}","git_commits_url":"https://api.github.com/repos/incuna/feincms-extensions/git/commits{/sha}","comments_url":"https://api.github.com/repos/incuna/feincms-extensions/comments{/number}","issue_comment_url":"https://api.github.com/repos/incuna/feincms-extensions/issues/comments{/number}","contents_url":"https://api.github.com/repos/incuna/feincms-extensions/contents/{+path}","compare_url":"https://api.github.com/repos/incuna/feincms-extensions/compare/{base}...{head}","merges_url":"https://api.github.com/repos/incuna/feincms-extensions/merges","archive_url":"https://api.github.com/repos/incuna/feincms-extensions/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/incuna/feincms-extensions/downloads","issues_url":"https://api.github.com/repos/incuna/feincms-extensions/issues{/number}","pulls_url":"https://api.github.com/repos/incuna/feincms-extensions/pulls{/number}","milestones_url":"https://api.github.com/repos/incuna/feincms-extensions/milestones{/number}","notifications_url":"https://api.github.com/repos/incuna/feincms-extensions/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/incuna/feincms-extensions/labels{/name}","releases_url":"https://api.github.com/repos/incuna/feincms-extensions/releases{/id}","created_at":"2014-06-06T09:19:05Z","updated_at":"2015-03-05T16:34:41Z","pushed_at":"2015-03-09T16:58:16Z","git_url":"git://github.com/incuna/feincms-extensions.git","ssh_url":"git@github.com:incuna/feincms-extensions.git","clone_url":"https://github.com/incuna/feincms-extensions.git","svn_url":"https://github.com/incuna/feincms-extensions","homepage":null,"size":376,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":0,"default_branch":"master"}},"base":{"label":"incuna:master","ref":"master","sha":"3e84ccb392dff65bb3b4cfd48fadaa4b8b691528","user":{"login":"incuna","id":55510,"avatar_url":"https://avatars.githubusercontent.com/u/55510?v=3","gravatar_id":"","url":"https://api.github.com/users/incuna","html_url":"https://github.com/incuna","followers_url":"https://api.github.com/users/incuna/followers","following_url":"https://api.github.com/users/incuna/following{/other_user}","gists_url":"https://api.github.com/users/incuna/gists{/gist_id}","starred_url":"https://api.github.com/users/incuna/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/incuna/subscriptions","organizations_url":"https://api.github.com/users/incuna/orgs","repos_url":"https://api.github.com/users/incuna/repos","events_url":"https://api.github.com/users/incuna/events{/privacy}","received_events_url":"https://api.github.com/users/incuna/received_events","type":"Organization","site_admin":false},"repo":{"id":20558038,"name":"feincms-extensions","full_name":"incuna/feincms-extensions","owner":{"login":"incuna","id":55510,"avatar_url":"https://avatars.githubusercontent.com/u/55510?v=3","gravatar_id":"","url":"https://api.github.com/users/incuna","html_url":"https://github.com/incuna","followers_url":"https://api.github.com/users/incuna/followers","following_url":"https://api.github.com/users/incuna/following{/other_user}","gists_url":"https://api.github.com/users/incuna/gists{/gist_id}","starred_url":"https://api.github.com/users/incuna/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/incuna/subscriptions","organizations_url":"https://api.github.com/users/incuna/orgs","repos_url":"https://api.github.com/users/incuna/repos","events_url":"https://api.github.com/users/incuna/events{/privacy}","received_events_url":"https://api.github.com/users/incuna/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/incuna/feincms-extensions","description":"","fork":false,"url":"https://api.github.com/repos/incuna/feincms-extensions","forks_url":"https://api.github.com/repos/incuna/feincms-extensions/forks","keys_url":"https://api.github.com/repos/incuna/feincms-extensions/keys{/key_id}","collaborators_url":"https://api.github.com/repos/incuna/feincms-extensions/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/incuna/feincms-extensions/teams","hooks_url":"https://api.github.com/repos/incuna/feincms-extensions/hooks","issue_events_url":"https://api.github.com/repos/incuna/feincms-extensions/issues/events{/number}","events_url":"https://api.github.com/repos/incuna/feincms-extensions/events","assignees_url":"https://api.github.com/repos/incuna/feincms-extensions/assignees{/user}","branches_url":"https://api.github.com/repos/incuna/feincms-extensions/branches{/branch}","tags_url":"https://api.github.com/repos/incuna/feincms-extensions/tags","blobs_url":"https://api.github.com/repos/incuna/feincms-extensions/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/incuna/feincms-extensions/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/incuna/feincms-extensions/git/refs{/sha}","trees_url":"https://api.github.com/repos/incuna/feincms-extensions/git/trees{/sha}","statuses_url":"https://api.github.com/repos/incuna/feincms-extensions/statuses/{sha}","languages_url":"https://api.github.com/repos/incuna/feincms-extensions/languages","stargazers_url":"https://api.github.com/repos/incuna/feincms-extensions/stargazers","contributors_url":"https://api.github.com/repos/incuna/feincms-extensions/contributors","subscribers_url":"https://api.github.com/repos/incuna/feincms-extensions/subscribers","subscription_url":"https://api.github.com/repos/incuna/feincms-extensions/subscription","commits_url":"https://api.github.com/repos/incuna/feincms-extensions/commits{/sha}","git_commits_url":"https://api.github.com/repos/incuna/feincms-extensions/git/commits{/sha}","comments_url":"https://api.github.com/repos/incuna/feincms-extensions/comments{/number}","issue_comment_url":"https://api.github.com/repos/incuna/feincms-extensions/issues/comments{/number}","contents_url":"https://api.github.com/repos/incuna/feincms-extensions/contents/{+path}","compare_url":"https://api.github.com/repos/incuna/feincms-extensions/compare/{base}...{head}","merges_url":"https://api.github.com/repos/incuna/feincms-extensions/merges","archive_url":"https://api.github.com/repos/incuna/feincms-extensions/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/incuna/feincms-extensions/downloads","issues_url":"https://api.github.com/repos/incuna/feincms-extensions/issues{/number}","pulls_url":"https://api.github.com/repos/incuna/feincms-extensions/pulls{/number}","milestones_url":"https://api.github.com/repos/incuna/feincms-extensions/milestones{/number}","notifications_url":"https://api.github.com/repos/incuna/feincms-extensions/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/incuna/feincms-extensions/labels{/name}","releases_url":"https://api.github.com/repos/incuna/feincms-extensions/releases{/id}","created_at":"2014-06-06T09:19:05Z","updated_at":"2015-03-05T16:34:41Z","pushed_at":"2015-03-09T16:58:16Z","git_url":"git://github.com/incuna/feincms-extensions.git","ssh_url":"git@github.com:incuna/feincms-extensions.git","clone_url":"https://github.com/incuna/feincms-extensions.git","svn_url":"https://github.com/incuna/feincms-extensions","homepage":null,"size":376,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/incuna/feincms-extensions/pulls/11"},"html":{"href":"https://github.com/incuna/feincms-extensions/pull/11"},"issue":{"href":"https://api.github.com/repos/incuna/feincms-extensions/issues/11"},"comments":{"href":"https://api.github.com/repos/incuna/feincms-extensions/issues/11/comments"},"review_comments":{"href":"https://api.github.com/repos/incuna/feincms-extensions/pulls/11/comments"},"review_comment":{"href":"https://api.github.com/repos/incuna/feincms-extensions/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/incuna/feincms-extensions/pulls/11/commits"},"statuses":{"href":"https://api.github.com/repos/incuna/feincms-extensions/statuses/d2eac598f7d3da3d1b65af43374ec9b5fe04a3d4"}}}}