{"action":"created","comment":{"url":"https://api.github.com/repos/MasterFacilityList/mfl_api/pulls/comments/27858833","id":27858833,"diff_hunk":"@@ -0,0 +1,52 @@\n+from rest_framework import serializers\n+from .models import Owner, Facility, Service\n+from common.serializers import AbstractFieldsMixin\n+\n+\n+class OwnerSerializer(AbstractFieldsMixin, serializers.ModelSerializer):\n+    class Meta:\n+        model = Owner\n+\n+\n+class ServiceSerializer(AbstractFieldsMixin, serializers.ModelSerializer):\n+    class Meta:\n+        model = Service\n+\n+\n+class FacilityReadSerializer(\n+        AbstractFieldsMixin, serializers.ModelSerializer):\n+\n+    class Meta:\n+        model = Facility\n+\n+\n+class FacilitySerializer(\n+        AbstractFieldsMixin, serializers.ModelSerializer):\n+    services = ServiceSerializer(many=True, required=False)\n+\n+    def create(self, validated_data):","path":"facilities/serializers.py","position":27,"original_position":27,"commit_id":"207d6e74b06b36cef47040cb2087442ae32e3f98","original_commit_id":"207d6e74b06b36cef47040cb2087442ae32e3f98","user":{"login":"ngurenyaga","id":220600,"avatar_url":"https://avatars.githubusercontent.com/u/220600?v=3","gravatar_id":"","url":"https://api.github.com/users/ngurenyaga","html_url":"https://github.com/ngurenyaga","followers_url":"https://api.github.com/users/ngurenyaga/followers","following_url":"https://api.github.com/users/ngurenyaga/following{/other_user}","gists_url":"https://api.github.com/users/ngurenyaga/gists{/gist_id}","starred_url":"https://api.github.com/users/ngurenyaga/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ngurenyaga/subscriptions","organizations_url":"https://api.github.com/users/ngurenyaga/orgs","repos_url":"https://api.github.com/users/ngurenyaga/repos","events_url":"https://api.github.com/users/ngurenyaga/events{/privacy}","received_events_url":"https://api.github.com/users/ngurenyaga/received_events","type":"User","site_admin":false},"body":"This is good code; but it will be simpler if we keep the API to simple, reliable CRUD; @liyosi and @owagaantony can create front-end wrappers that do this stuff that you are doing here.\r\n\r\ni.e. unless there is a direct request and a good reason, let M2M fields be manipulated through the join tables.\r\n\r\nFor the front-enders: @owagaantony @sombo09 @liyosi  - design the data input forms so that _it is natural to save the \"header\" information first_.","created_at":"2015-04-07T08:16:45Z","updated_at":"2015-04-07T08:16:45Z","html_url":"https://github.com/MasterFacilityList/mfl_api/pull/30#discussion_r27858833","pull_request_url":"https://api.github.com/repos/MasterFacilityList/mfl_api/pulls/30","_links":{"self":{"href":"https://api.github.com/repos/MasterFacilityList/mfl_api/pulls/comments/27858833"},"html":{"href":"https://github.com/MasterFacilityList/mfl_api/pull/30#discussion_r27858833"},"pull_request":{"href":"https://api.github.com/repos/MasterFacilityList/mfl_api/pulls/30"}}},"pull_request":{"url":"https://api.github.com/repos/MasterFacilityList/mfl_api/pulls/30","id":32738932,"html_url":"https://github.com/MasterFacilityList/mfl_api/pull/30","diff_url":"https://github.com/MasterFacilityList/mfl_api/pull/30.diff","patch_url":"https://github.com/MasterFacilityList/mfl_api/pull/30.patch","issue_url":"https://api.github.com/repos/MasterFacilityList/mfl_api/issues/30","number":30,"state":"open","locked":false,"title":"Common models","user":{"login":"ngurenyaga","id":220600,"avatar_url":"https://avatars.githubusercontent.com/u/220600?v=3","gravatar_id":"","url":"https://api.github.com/users/ngurenyaga","html_url":"https://github.com/ngurenyaga","followers_url":"https://api.github.com/users/ngurenyaga/followers","following_url":"https://api.github.com/users/ngurenyaga/following{/other_user}","gists_url":"https://api.github.com/users/ngurenyaga/gists{/gist_id}","starred_url":"https://api.github.com/users/ngurenyaga/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ngurenyaga/subscriptions","organizations_url":"https://api.github.com/users/ngurenyaga/orgs","repos_url":"https://api.github.com/users/ngurenyaga/repos","events_url":"https://api.github.com/users/ngurenyaga/events{/privacy}","received_events_url":"https://api.github.com/users/ngurenyaga/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-04-07T07:18:01Z","updated_at":"2015-04-07T08:16:45Z","closed_at":null,"merged_at":null,"merge_commit_sha":"153264c1c41a8b2486bcd328ba199a5d9f8dcd36","assignee":{"login":"bmarika","id":6511753,"avatar_url":"https://avatars.githubusercontent.com/u/6511753?v=3","gravatar_id":"","url":"https://api.github.com/users/bmarika","html_url":"https://github.com/bmarika","followers_url":"https://api.github.com/users/bmarika/followers","following_url":"https://api.github.com/users/bmarika/following{/other_user}","gists_url":"https://api.github.com/users/bmarika/gists{/gist_id}","starred_url":"https://api.github.com/users/bmarika/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bmarika/subscriptions","organizations_url":"https://api.github.com/users/bmarika/orgs","repos_url":"https://api.github.com/users/bmarika/repos","events_url":"https://api.github.com/users/bmarika/events{/privacy}","received_events_url":"https://api.github.com/users/bmarika/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/MasterFacilityList/mfl_api/milestones/1","html_url":"https://github.com/MasterFacilityList/mfl_api/milestones/ALPHA","labels_url":"https://api.github.com/repos/MasterFacilityList/mfl_api/milestones/1/labels","id":1044206,"number":1,"title":"ALPHA","description":null,"creator":{"login":"ngurenyaga","id":220600,"avatar_url":"https://avatars.githubusercontent.com/u/220600?v=3","gravatar_id":"","url":"https://api.github.com/users/ngurenyaga","html_url":"https://github.com/ngurenyaga","followers_url":"https://api.github.com/users/ngurenyaga/followers","following_url":"https://api.github.com/users/ngurenyaga/following{/other_user}","gists_url":"https://api.github.com/users/ngurenyaga/gists{/gist_id}","starred_url":"https://api.github.com/users/ngurenyaga/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ngurenyaga/subscriptions","organizations_url":"https://api.github.com/users/ngurenyaga/orgs","repos_url":"https://api.github.com/users/ngurenyaga/repos","events_url":"https://api.github.com/users/ngurenyaga/events{/privacy}","received_events_url":"https://api.github.com/users/ngurenyaga/received_events","type":"User","site_admin":false},"open_issues":27,"closed_issues":0,"state":"open","created_at":"2015-03-30T07:55:01Z","updated_at":"2015-04-07T07:18:01Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/MasterFacilityList/mfl_api/pulls/30/commits","review_comments_url":"https://api.github.com/repos/MasterFacilityList/mfl_api/pulls/30/comments","review_comment_url":"https://api.github.com/repos/MasterFacilityList/mfl_api/pulls/comments{/number}","comments_url":"https://api.github.com/repos/MasterFacilityList/mfl_api/issues/30/comments","statuses_url":"https://api.github.com/repos/MasterFacilityList/mfl_api/statuses/207d6e74b06b36cef47040cb2087442ae32e3f98","head":{"label":"MasterFacilityList:common_models","ref":"common_models","sha":"207d6e74b06b36cef47040cb2087442ae32e3f98","user":{"login":"MasterFacilityList","id":11611058,"avatar_url":"https://avatars.githubusercontent.com/u/11611058?v=3","gravatar_id":"","url":"https://api.github.com/users/MasterFacilityList","html_url":"https://github.com/MasterFacilityList","followers_url":"https://api.github.com/users/MasterFacilityList/followers","following_url":"https://api.github.com/users/MasterFacilityList/following{/other_user}","gists_url":"https://api.github.com/users/MasterFacilityList/gists{/gist_id}","starred_url":"https://api.github.com/users/MasterFacilityList/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MasterFacilityList/subscriptions","organizations_url":"https://api.github.com/users/MasterFacilityList/orgs","repos_url":"https://api.github.com/users/MasterFacilityList/repos","events_url":"https://api.github.com/users/MasterFacilityList/events{/privacy}","received_events_url":"https://api.github.com/users/MasterFacilityList/received_events","type":"Organization","site_admin":false},"repo":{"id":32854024,"name":"mfl_api","full_name":"MasterFacilityList/mfl_api","owner":{"login":"MasterFacilityList","id":11611058,"avatar_url":"https://avatars.githubusercontent.com/u/11611058?v=3","gravatar_id":"","url":"https://api.github.com/users/MasterFacilityList","html_url":"https://github.com/MasterFacilityList","followers_url":"https://api.github.com/users/MasterFacilityList/followers","following_url":"https://api.github.com/users/MasterFacilityList/following{/other_user}","gists_url":"https://api.github.com/users/MasterFacilityList/gists{/gist_id}","starred_url":"https://api.github.com/users/MasterFacilityList/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MasterFacilityList/subscriptions","organizations_url":"https://api.github.com/users/MasterFacilityList/orgs","repos_url":"https://api.github.com/users/MasterFacilityList/repos","events_url":"https://api.github.com/users/MasterFacilityList/events{/privacy}","received_events_url":"https://api.github.com/users/MasterFacilityList/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/MasterFacilityList/mfl_api","description":"The master facilty list Kenya","fork":false,"url":"https://api.github.com/repos/MasterFacilityList/mfl_api","forks_url":"https://api.github.com/repos/MasterFacilityList/mfl_api/forks","keys_url":"https://api.github.com/repos/MasterFacilityList/mfl_api/keys{/key_id}","collaborators_url":"https://api.github.com/repos/MasterFacilityList/mfl_api/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/MasterFacilityList/mfl_api/teams","hooks_url":"https://api.github.com/repos/MasterFacilityList/mfl_api/hooks","issue_events_url":"https://api.github.com/repos/MasterFacilityList/mfl_api/issues/events{/number}","events_url":"https://api.github.com/repos/MasterFacilityList/mfl_api/events","assignees_url":"https://api.github.com/repos/MasterFacilityList/mfl_api/assignees{/user}","branches_url":"https://api.github.com/repos/MasterFacilityList/mfl_api/branches{/branch}","tags_url":"https://api.github.com/repos/MasterFacilityList/mfl_api/tags","blobs_url":"https://api.github.com/repos/MasterFacilityList/mfl_api/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/MasterFacilityList/mfl_api/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/MasterFacilityList/mfl_api/git/refs{/sha}","trees_url":"https://api.github.com/repos/MasterFacilityList/mfl_api/git/trees{/sha}","statuses_url":"https://api.github.com/repos/MasterFacilityList/mfl_api/statuses/{sha}","languages_url":"https://api.github.com/repos/MasterFacilityList/mfl_api/languages","stargazers_url":"https://api.github.com/repos/MasterFacilityList/mfl_api/stargazers","contributors_url":"https://api.github.com/repos/MasterFacilityList/mfl_api/contributors","subscribers_url":"https://api.github.com/repos/MasterFacilityList/mfl_api/subscribers","subscription_url":"https://api.github.com/repos/MasterFacilityList/mfl_api/subscription","commits_url":"https://api.github.com/repos/MasterFacilityList/mfl_api/commits{/sha}","git_commits_url":"https://api.github.com/repos/MasterFacilityList/mfl_api/git/commits{/sha}","comments_url":"https://api.github.com/repos/MasterFacilityList/mfl_api/comments{/number}","issue_comment_url":"https://api.github.com/repos/MasterFacilityList/mfl_api/issues/comments{/number}","contents_url":"https://api.github.com/repos/MasterFacilityList/mfl_api/contents/{+path}","compare_url":"https://api.github.com/repos/MasterFacilityList/mfl_api/compare/{base}...{head}","merges_url":"https://api.github.com/repos/MasterFacilityList/mfl_api/merges","archive_url":"https://api.github.com/repos/MasterFacilityList/mfl_api/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/MasterFacilityList/mfl_api/downloads","issues_url":"https://api.github.com/repos/MasterFacilityList/mfl_api/issues{/number}","pulls_url":"https://api.github.com/repos/MasterFacilityList/mfl_api/pulls{/number}","milestones_url":"https://api.github.com/repos/MasterFacilityList/mfl_api/milestones{/number}","notifications_url":"https://api.github.com/repos/MasterFacilityList/mfl_api/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/MasterFacilityList/mfl_api/labels{/name}","releases_url":"https://api.github.com/repos/MasterFacilityList/mfl_api/releases{/id}","created_at":"2015-03-25T09:14:34Z","updated_at":"2015-03-30T05:08:46Z","pushed_at":"2015-04-07T07:18:01Z","git_url":"git://github.com/MasterFacilityList/mfl_api.git","ssh_url":"git@github.com:MasterFacilityList/mfl_api.git","clone_url":"https://github.com/MasterFacilityList/mfl_api.git","svn_url":"https://github.com/MasterFacilityList/mfl_api","homepage":"https://www.ehealth.or.ke","size":256,"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":29,"forks":0,"open_issues":29,"watchers":0,"default_branch":"master"}},"base":{"label":"MasterFacilityList:master","ref":"master","sha":"9bab59df3e186842f416e5fa63d298a9d8967e6e","user":{"login":"MasterFacilityList","id":11611058,"avatar_url":"https://avatars.githubusercontent.com/u/11611058?v=3","gravatar_id":"","url":"https://api.github.com/users/MasterFacilityList","html_url":"https://github.com/MasterFacilityList","followers_url":"https://api.github.com/users/MasterFacilityList/followers","following_url":"https://api.github.com/users/MasterFacilityList/following{/other_user}","gists_url":"https://api.github.com/users/MasterFacilityList/gists{/gist_id}","starred_url":"https://api.github.com/users/MasterFacilityList/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MasterFacilityList/subscriptions","organizations_url":"https://api.github.com/users/MasterFacilityList/orgs","repos_url":"https://api.github.com/users/MasterFacilityList/repos","events_url":"https://api.github.com/users/MasterFacilityList/events{/privacy}","received_events_url":"https://api.github.com/users/MasterFacilityList/received_events","type":"Organization","site_admin":false},"repo":{"id":32854024,"name":"mfl_api","full_name":"MasterFacilityList/mfl_api","owner":{"login":"MasterFacilityList","id":11611058,"avatar_url":"https://avatars.githubusercontent.com/u/11611058?v=3","gravatar_id":"","url":"https://api.github.com/users/MasterFacilityList","html_url":"https://github.com/MasterFacilityList","followers_url":"https://api.github.com/users/MasterFacilityList/followers","following_url":"https://api.github.com/users/MasterFacilityList/following{/other_user}","gists_url":"https://api.github.com/users/MasterFacilityList/gists{/gist_id}","starred_url":"https://api.github.com/users/MasterFacilityList/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MasterFacilityList/subscriptions","organizations_url":"https://api.github.com/users/MasterFacilityList/orgs","repos_url":"https://api.github.com/users/MasterFacilityList/repos","events_url":"https://api.github.com/users/MasterFacilityList/events{/privacy}","received_events_url":"https://api.github.com/users/MasterFacilityList/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/MasterFacilityList/mfl_api","description":"The master facilty list Kenya","fork":false,"url":"https://api.github.com/repos/MasterFacilityList/mfl_api","forks_url":"https://api.github.com/repos/MasterFacilityList/mfl_api/forks","keys_url":"https://api.github.com/repos/MasterFacilityList/mfl_api/keys{/key_id}","collaborators_url":"https://api.github.com/repos/MasterFacilityList/mfl_api/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/MasterFacilityList/mfl_api/teams","hooks_url":"https://api.github.com/repos/MasterFacilityList/mfl_api/hooks","issue_events_url":"https://api.github.com/repos/MasterFacilityList/mfl_api/issues/events{/number}","events_url":"https://api.github.com/repos/MasterFacilityList/mfl_api/events","assignees_url":"https://api.github.com/repos/MasterFacilityList/mfl_api/assignees{/user}","branches_url":"https://api.github.com/repos/MasterFacilityList/mfl_api/branches{/branch}","tags_url":"https://api.github.com/repos/MasterFacilityList/mfl_api/tags","blobs_url":"https://api.github.com/repos/MasterFacilityList/mfl_api/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/MasterFacilityList/mfl_api/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/MasterFacilityList/mfl_api/git/refs{/sha}","trees_url":"https://api.github.com/repos/MasterFacilityList/mfl_api/git/trees{/sha}","statuses_url":"https://api.github.com/repos/MasterFacilityList/mfl_api/statuses/{sha}","languages_url":"https://api.github.com/repos/MasterFacilityList/mfl_api/languages","stargazers_url":"https://api.github.com/repos/MasterFacilityList/mfl_api/stargazers","contributors_url":"https://api.github.com/repos/MasterFacilityList/mfl_api/contributors","subscribers_url":"https://api.github.com/repos/MasterFacilityList/mfl_api/subscribers","subscription_url":"https://api.github.com/repos/MasterFacilityList/mfl_api/subscription","commits_url":"https://api.github.com/repos/MasterFacilityList/mfl_api/commits{/sha}","git_commits_url":"https://api.github.com/repos/MasterFacilityList/mfl_api/git/commits{/sha}","comments_url":"https://api.github.com/repos/MasterFacilityList/mfl_api/comments{/number}","issue_comment_url":"https://api.github.com/repos/MasterFacilityList/mfl_api/issues/comments{/number}","contents_url":"https://api.github.com/repos/MasterFacilityList/mfl_api/contents/{+path}","compare_url":"https://api.github.com/repos/MasterFacilityList/mfl_api/compare/{base}...{head}","merges_url":"https://api.github.com/repos/MasterFacilityList/mfl_api/merges","archive_url":"https://api.github.com/repos/MasterFacilityList/mfl_api/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/MasterFacilityList/mfl_api/downloads","issues_url":"https://api.github.com/repos/MasterFacilityList/mfl_api/issues{/number}","pulls_url":"https://api.github.com/repos/MasterFacilityList/mfl_api/pulls{/number}","milestones_url":"https://api.github.com/repos/MasterFacilityList/mfl_api/milestones{/number}","notifications_url":"https://api.github.com/repos/MasterFacilityList/mfl_api/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/MasterFacilityList/mfl_api/labels{/name}","releases_url":"https://api.github.com/repos/MasterFacilityList/mfl_api/releases{/id}","created_at":"2015-03-25T09:14:34Z","updated_at":"2015-03-30T05:08:46Z","pushed_at":"2015-04-07T07:18:01Z","git_url":"git://github.com/MasterFacilityList/mfl_api.git","ssh_url":"git@github.com:MasterFacilityList/mfl_api.git","clone_url":"https://github.com/MasterFacilityList/mfl_api.git","svn_url":"https://github.com/MasterFacilityList/mfl_api","homepage":"https://www.ehealth.or.ke","size":256,"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":29,"forks":0,"open_issues":29,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/MasterFacilityList/mfl_api/pulls/30"},"html":{"href":"https://github.com/MasterFacilityList/mfl_api/pull/30"},"issue":{"href":"https://api.github.com/repos/MasterFacilityList/mfl_api/issues/30"},"comments":{"href":"https://api.github.com/repos/MasterFacilityList/mfl_api/issues/30/comments"},"review_comments":{"href":"https://api.github.com/repos/MasterFacilityList/mfl_api/pulls/30/comments"},"review_comment":{"href":"https://api.github.com/repos/MasterFacilityList/mfl_api/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/MasterFacilityList/mfl_api/pulls/30/commits"},"statuses":{"href":"https://api.github.com/repos/MasterFacilityList/mfl_api/statuses/207d6e74b06b36cef47040cb2087442ae32e3f98"}}}}