{"action":"created","comment":{"url":"https://api.github.com/repos/edx/credentials/pulls/comments/48023080","id":48023080,"diff_hunk":"@@ -1,4 +1,92 @@\n-# Serializers that can be shared across multiple versions of the API\n-# should be created here. As the API evolves, serializers may become more\n-# specific to a particular version of the API. In this case, the serializers\n-# in question should be moved to versioned sub-package.\n+\"\"\"\n+Serializers for data manipulated by the credentials service APIs.\n+\"\"\"\n+from rest_framework import serializers\n+\n+from credentials.apps.credentials.models import (\n+    ProgramCertificate, CourseCertificate,\n+    UserCredentialAttribute, UserCredential\n+)\n+\n+\n+class CredentialRelatedField(serializers.RelatedField):  # pylint: disable=abstract-method\n+    \"\"\"\n+    A custom field to use for the user credential generic relationship.\n+    \"\"\"\n+\n+    def to_representation(self, value):\n+        \"\"\"\n+        Serialize objects to a according to model content-type.\n+        \"\"\"\n+        if isinstance(value, ProgramCertificate):\n+            return {\n+                'program_id': value.program_id\n+            }\n+        elif isinstance(value, CourseCertificate):\n+            return {\n+                'course_id': value.course_id,\n+                'certificate_type': value.certificate_type\n+            }\n+\n+\n+class UserCredentialAttributeSerializer(serializers.ModelSerializer):\n+    \"\"\" Serializer for CredentialAttribute objects \"\"\"\n+\n+    class Meta(object):\n+        model = UserCredentialAttribute\n+        fields = ('namespace', 'name', 'value')\n+\n+\n+class UserCredentialSerializer(serializers.ModelSerializer):\n+    \"\"\" Serializer for User Credential objects. \"\"\"\n+\n+    credential = CredentialRelatedField(read_only='True')\n+    attributes = UserCredentialAttributeSerializer(many=True, read_only=True)\n+\n+    class Meta(object):\n+        model = UserCredential\n+        fields = (","path":"credentials/apps/api/serializers.py","position":53,"original_position":52,"commit_id":"5846a61eadb96a705c04bece4d8a6a53ef4469bf","original_commit_id":"db8fdeeae7661fc97c4e732d556ae38964db7f2a","user":{"login":"tasawernawaz","id":4245618,"avatar_url":"https://avatars.githubusercontent.com/u/4245618?v=3","gravatar_id":"","url":"https://api.github.com/users/tasawernawaz","html_url":"https://github.com/tasawernawaz","followers_url":"https://api.github.com/users/tasawernawaz/followers","following_url":"https://api.github.com/users/tasawernawaz/following{/other_user}","gists_url":"https://api.github.com/users/tasawernawaz/gists{/gist_id}","starred_url":"https://api.github.com/users/tasawernawaz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tasawernawaz/subscriptions","organizations_url":"https://api.github.com/users/tasawernawaz/orgs","repos_url":"https://api.github.com/users/tasawernawaz/repos","events_url":"https://api.github.com/users/tasawernawaz/events{/privacy}","received_events_url":"https://api.github.com/users/tasawernawaz/received_events","type":"User","site_admin":false},"body":"We are adding `credential` and `attributes` in the fields with exclusion of `created` and `modified`. ","created_at":"2015-12-18T13:10:50Z","updated_at":"2015-12-18T13:10:50Z","html_url":"https://github.com/edx/credentials/pull/2#discussion_r48023080","pull_request_url":"https://api.github.com/repos/edx/credentials/pulls/2","_links":{"self":{"href":"https://api.github.com/repos/edx/credentials/pulls/comments/48023080"},"html":{"href":"https://github.com/edx/credentials/pull/2#discussion_r48023080"},"pull_request":{"href":"https://api.github.com/repos/edx/credentials/pulls/2"}}},"pull_request":{"url":"https://api.github.com/repos/edx/credentials/pulls/2","id":53697609,"html_url":"https://github.com/edx/credentials/pull/2","diff_url":"https://github.com/edx/credentials/pull/2.diff","patch_url":"https://github.com/edx/credentials/pull/2.patch","issue_url":"https://api.github.com/repos/edx/credentials/issues/2","number":2,"state":"open","locked":false,"title":"User Credentials api","user":{"login":"awais786","id":445320,"avatar_url":"https://avatars.githubusercontent.com/u/445320?v=3","gravatar_id":"","url":"https://api.github.com/users/awais786","html_url":"https://github.com/awais786","followers_url":"https://api.github.com/users/awais786/followers","following_url":"https://api.github.com/users/awais786/following{/other_user}","gists_url":"https://api.github.com/users/awais786/gists{/gist_id}","starred_url":"https://api.github.com/users/awais786/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/awais786/subscriptions","organizations_url":"https://api.github.com/users/awais786/orgs","repos_url":"https://api.github.com/users/awais786/repos","events_url":"https://api.github.com/users/awais786/events{/privacy}","received_events_url":"https://api.github.com/users/awais786/received_events","type":"User","site_admin":false},"body":"WIP ECOM-2999\r\nAdding the end-points to create the user credentials. One end-point will be use to create different types of credentials. Accreditor class will be use for this purpose.\r\nAt the moment few test cases are failing and also need to implement authentication.\r\nClasses implementation.\r\nhttps://github.com/edx/edx-platform/commit/84699260e06199b8a41c3765260dc35cf619e4c1","created_at":"2015-12-15T12:36:53Z","updated_at":"2015-12-18T13:10:50Z","closed_at":null,"merged_at":null,"merge_commit_sha":"14446d1c69940aea45c6f0f384cc908ad2f04c9c","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/edx/credentials/pulls/2/commits","review_comments_url":"https://api.github.com/repos/edx/credentials/pulls/2/comments","review_comment_url":"https://api.github.com/repos/edx/credentials/pulls/comments{/number}","comments_url":"https://api.github.com/repos/edx/credentials/issues/2/comments","statuses_url":"https://api.github.com/repos/edx/credentials/statuses/5846a61eadb96a705c04bece4d8a6a53ef4469bf","head":{"label":"edx:awais786/ECOM-2999-user-credential-apis","ref":"awais786/ECOM-2999-user-credential-apis","sha":"5846a61eadb96a705c04bece4d8a6a53ef4469bf","user":{"login":"edx","id":3179841,"avatar_url":"https://avatars.githubusercontent.com/u/3179841?v=3","gravatar_id":"","url":"https://api.github.com/users/edx","html_url":"https://github.com/edx","followers_url":"https://api.github.com/users/edx/followers","following_url":"https://api.github.com/users/edx/following{/other_user}","gists_url":"https://api.github.com/users/edx/gists{/gist_id}","starred_url":"https://api.github.com/users/edx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edx/subscriptions","organizations_url":"https://api.github.com/users/edx/orgs","repos_url":"https://api.github.com/users/edx/repos","events_url":"https://api.github.com/users/edx/events{/privacy}","received_events_url":"https://api.github.com/users/edx/received_events","type":"Organization","site_admin":false},"repo":{"id":47830104,"name":"credentials","full_name":"edx/credentials","owner":{"login":"edx","id":3179841,"avatar_url":"https://avatars.githubusercontent.com/u/3179841?v=3","gravatar_id":"","url":"https://api.github.com/users/edx","html_url":"https://github.com/edx","followers_url":"https://api.github.com/users/edx/followers","following_url":"https://api.github.com/users/edx/following{/other_user}","gists_url":"https://api.github.com/users/edx/gists{/gist_id}","starred_url":"https://api.github.com/users/edx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edx/subscriptions","organizations_url":"https://api.github.com/users/edx/orgs","repos_url":"https://api.github.com/users/edx/repos","events_url":"https://api.github.com/users/edx/events{/privacy}","received_events_url":"https://api.github.com/users/edx/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/edx/credentials","description":"Django application used as the backend to support Course or Program based credentials.","fork":false,"url":"https://api.github.com/repos/edx/credentials","forks_url":"https://api.github.com/repos/edx/credentials/forks","keys_url":"https://api.github.com/repos/edx/credentials/keys{/key_id}","collaborators_url":"https://api.github.com/repos/edx/credentials/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/edx/credentials/teams","hooks_url":"https://api.github.com/repos/edx/credentials/hooks","issue_events_url":"https://api.github.com/repos/edx/credentials/issues/events{/number}","events_url":"https://api.github.com/repos/edx/credentials/events","assignees_url":"https://api.github.com/repos/edx/credentials/assignees{/user}","branches_url":"https://api.github.com/repos/edx/credentials/branches{/branch}","tags_url":"https://api.github.com/repos/edx/credentials/tags","blobs_url":"https://api.github.com/repos/edx/credentials/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/edx/credentials/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/edx/credentials/git/refs{/sha}","trees_url":"https://api.github.com/repos/edx/credentials/git/trees{/sha}","statuses_url":"https://api.github.com/repos/edx/credentials/statuses/{sha}","languages_url":"https://api.github.com/repos/edx/credentials/languages","stargazers_url":"https://api.github.com/repos/edx/credentials/stargazers","contributors_url":"https://api.github.com/repos/edx/credentials/contributors","subscribers_url":"https://api.github.com/repos/edx/credentials/subscribers","subscription_url":"https://api.github.com/repos/edx/credentials/subscription","commits_url":"https://api.github.com/repos/edx/credentials/commits{/sha}","git_commits_url":"https://api.github.com/repos/edx/credentials/git/commits{/sha}","comments_url":"https://api.github.com/repos/edx/credentials/comments{/number}","issue_comment_url":"https://api.github.com/repos/edx/credentials/issues/comments{/number}","contents_url":"https://api.github.com/repos/edx/credentials/contents/{+path}","compare_url":"https://api.github.com/repos/edx/credentials/compare/{base}...{head}","merges_url":"https://api.github.com/repos/edx/credentials/merges","archive_url":"https://api.github.com/repos/edx/credentials/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/edx/credentials/downloads","issues_url":"https://api.github.com/repos/edx/credentials/issues{/number}","pulls_url":"https://api.github.com/repos/edx/credentials/pulls{/number}","milestones_url":"https://api.github.com/repos/edx/credentials/milestones{/number}","notifications_url":"https://api.github.com/repos/edx/credentials/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/edx/credentials/labels{/name}","releases_url":"https://api.github.com/repos/edx/credentials/releases{/id}","created_at":"2015-12-11T14:09:03Z","updated_at":"2015-12-14T20:00:22Z","pushed_at":"2015-12-18T12:55:49Z","git_url":"git://github.com/edx/credentials.git","ssh_url":"git@github.com:edx/credentials.git","clone_url":"https://github.com/edx/credentials.git","svn_url":"https://github.com/edx/credentials","homepage":"http://open-edx-credentials-guide.readthedocs.org/en/latest/ ","size":1174,"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":"edx:master","ref":"master","sha":"3ef030df80a053773cf33587d30612fe41f5cf92","user":{"login":"edx","id":3179841,"avatar_url":"https://avatars.githubusercontent.com/u/3179841?v=3","gravatar_id":"","url":"https://api.github.com/users/edx","html_url":"https://github.com/edx","followers_url":"https://api.github.com/users/edx/followers","following_url":"https://api.github.com/users/edx/following{/other_user}","gists_url":"https://api.github.com/users/edx/gists{/gist_id}","starred_url":"https://api.github.com/users/edx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edx/subscriptions","organizations_url":"https://api.github.com/users/edx/orgs","repos_url":"https://api.github.com/users/edx/repos","events_url":"https://api.github.com/users/edx/events{/privacy}","received_events_url":"https://api.github.com/users/edx/received_events","type":"Organization","site_admin":false},"repo":{"id":47830104,"name":"credentials","full_name":"edx/credentials","owner":{"login":"edx","id":3179841,"avatar_url":"https://avatars.githubusercontent.com/u/3179841?v=3","gravatar_id":"","url":"https://api.github.com/users/edx","html_url":"https://github.com/edx","followers_url":"https://api.github.com/users/edx/followers","following_url":"https://api.github.com/users/edx/following{/other_user}","gists_url":"https://api.github.com/users/edx/gists{/gist_id}","starred_url":"https://api.github.com/users/edx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edx/subscriptions","organizations_url":"https://api.github.com/users/edx/orgs","repos_url":"https://api.github.com/users/edx/repos","events_url":"https://api.github.com/users/edx/events{/privacy}","received_events_url":"https://api.github.com/users/edx/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/edx/credentials","description":"Django application used as the backend to support Course or Program based credentials.","fork":false,"url":"https://api.github.com/repos/edx/credentials","forks_url":"https://api.github.com/repos/edx/credentials/forks","keys_url":"https://api.github.com/repos/edx/credentials/keys{/key_id}","collaborators_url":"https://api.github.com/repos/edx/credentials/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/edx/credentials/teams","hooks_url":"https://api.github.com/repos/edx/credentials/hooks","issue_events_url":"https://api.github.com/repos/edx/credentials/issues/events{/number}","events_url":"https://api.github.com/repos/edx/credentials/events","assignees_url":"https://api.github.com/repos/edx/credentials/assignees{/user}","branches_url":"https://api.github.com/repos/edx/credentials/branches{/branch}","tags_url":"https://api.github.com/repos/edx/credentials/tags","blobs_url":"https://api.github.com/repos/edx/credentials/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/edx/credentials/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/edx/credentials/git/refs{/sha}","trees_url":"https://api.github.com/repos/edx/credentials/git/trees{/sha}","statuses_url":"https://api.github.com/repos/edx/credentials/statuses/{sha}","languages_url":"https://api.github.com/repos/edx/credentials/languages","stargazers_url":"https://api.github.com/repos/edx/credentials/stargazers","contributors_url":"https://api.github.com/repos/edx/credentials/contributors","subscribers_url":"https://api.github.com/repos/edx/credentials/subscribers","subscription_url":"https://api.github.com/repos/edx/credentials/subscription","commits_url":"https://api.github.com/repos/edx/credentials/commits{/sha}","git_commits_url":"https://api.github.com/repos/edx/credentials/git/commits{/sha}","comments_url":"https://api.github.com/repos/edx/credentials/comments{/number}","issue_comment_url":"https://api.github.com/repos/edx/credentials/issues/comments{/number}","contents_url":"https://api.github.com/repos/edx/credentials/contents/{+path}","compare_url":"https://api.github.com/repos/edx/credentials/compare/{base}...{head}","merges_url":"https://api.github.com/repos/edx/credentials/merges","archive_url":"https://api.github.com/repos/edx/credentials/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/edx/credentials/downloads","issues_url":"https://api.github.com/repos/edx/credentials/issues{/number}","pulls_url":"https://api.github.com/repos/edx/credentials/pulls{/number}","milestones_url":"https://api.github.com/repos/edx/credentials/milestones{/number}","notifications_url":"https://api.github.com/repos/edx/credentials/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/edx/credentials/labels{/name}","releases_url":"https://api.github.com/repos/edx/credentials/releases{/id}","created_at":"2015-12-11T14:09:03Z","updated_at":"2015-12-14T20:00:22Z","pushed_at":"2015-12-18T12:55:49Z","git_url":"git://github.com/edx/credentials.git","ssh_url":"git@github.com:edx/credentials.git","clone_url":"https://github.com/edx/credentials.git","svn_url":"https://github.com/edx/credentials","homepage":"http://open-edx-credentials-guide.readthedocs.org/en/latest/ ","size":1174,"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/edx/credentials/pulls/2"},"html":{"href":"https://github.com/edx/credentials/pull/2"},"issue":{"href":"https://api.github.com/repos/edx/credentials/issues/2"},"comments":{"href":"https://api.github.com/repos/edx/credentials/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/edx/credentials/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/edx/credentials/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/edx/credentials/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/edx/credentials/statuses/5846a61eadb96a705c04bece4d8a6a53ef4469bf"}}}}