{"action":"created","comment":{"url":"https://api.github.com/repos/edx/course-discovery/pulls/comments/140353909","pull_request_review_id":64416614,"id":140353909,"diff_hunk":"@@ -0,0 +1,58 @@\n+# -*- coding: utf-8 -*-\n+# Generated by Django 1.11.3 on 2017-09-11 17:06\n+from __future__ import unicode_literals\n+\n+from django.db import migrations\n+from django.conf import settings\n+from django.core.exceptions import ObjectDoesNotExist\n+\n+\n+def forwards_func(apps, schema_editor):\n+    Subject = apps.get_model('course_metadata', 'Subject')\n+    SubjectTranslation = apps.get_model('course_metadata', 'SubjectTranslation')\n+\n+    for object in Subject.objects.all():\n+\n+        SubjectTranslation.objects.create(\n+            master_id=object.pk,\n+            language_code=settings.LANGUAGE_CODE,\n+            name_t=object.name,\n+            subtitle_t=object.subtitle,\n+            description_t=object.description\n+        )\n+\n+def backwards_func(apps, schema_editor):\n+    Subject = apps.get_model('course_metadata', 'Subject')\n+    SubjectTranslation = apps.get_model('course_metadata', 'SubjectTranslation')\n+\n+    for object in Subject.objects.all():\n+        translation = _get_translation(object, SubjectTranslation)\n+        object.name = translation.name_t\n+        object.subtitle = translation.subtitle_t\n+        object.description = translation.description_t\n+        object.save()   # Note this only calls Model.save()\n+\n+def _get_translation(object, SubjectTranslation):\n+    translations = SubjectTranslation.objects.filter(master_id=object.pk)\n+    try:\n+        # Try default translation\n+        return translations.get(language_code=settings.LANGUAGE_CODE)\n+    except ObjectDoesNotExist:\n+        try:\n+            # Try default language\n+            return translations.get(language_code=settings.PARLER_DEFAULT_LANGUAGE_CODE)","path":"course_discovery/apps/course_metadata/migrations/0059_make_translations_table.py","position":43,"original_position":43,"commit_id":"e66489c2c932bbaac42823dbef93718e8320eb93","original_commit_id":"e66489c2c932bbaac42823dbef93718e8320eb93","user":{"login":"amangano-edx","id":24230895,"avatar_url":"https://avatars2.githubusercontent.com/u/24230895?v=4","gravatar_id":"","url":"https://api.github.com/users/amangano-edx","html_url":"https://github.com/amangano-edx","followers_url":"https://api.github.com/users/amangano-edx/followers","following_url":"https://api.github.com/users/amangano-edx/following{/other_user}","gists_url":"https://api.github.com/users/amangano-edx/gists{/gist_id}","starred_url":"https://api.github.com/users/amangano-edx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amangano-edx/subscriptions","organizations_url":"https://api.github.com/users/amangano-edx/orgs","repos_url":"https://api.github.com/users/amangano-edx/repos","events_url":"https://api.github.com/users/amangano-edx/events{/privacy}","received_events_url":"https://api.github.com/users/amangano-edx/received_events","type":"User","site_admin":false},"body":"What is `PARLER_DEFAULT_LANGUAGE_CODE` and how is it different from our default language code?","created_at":"2017-09-21T20:43:05Z","updated_at":"2017-09-21T20:43:05Z","html_url":"https://github.com/edx/course-discovery/pull/1129#discussion_r140353909","pull_request_url":"https://api.github.com/repos/edx/course-discovery/pulls/1129","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/edx/course-discovery/pulls/comments/140353909"},"html":{"href":"https://github.com/edx/course-discovery/pull/1129#discussion_r140353909"},"pull_request":{"href":"https://api.github.com/repos/edx/course-discovery/pulls/1129"}}},"pull_request":{"url":"https://api.github.com/repos/edx/course-discovery/pulls/1129","id":142158167,"html_url":"https://github.com/edx/course-discovery/pull/1129","diff_url":"https://github.com/edx/course-discovery/pull/1129.diff","patch_url":"https://github.com/edx/course-discovery/pull/1129.patch","issue_url":"https://api.github.com/repos/edx/course-discovery/issues/1129","number":1129,"state":"open","locked":false,"title":"WIP: Add translations to the Subjects model","user":{"login":"BenjiLee","id":7101723,"avatar_url":"https://avatars1.githubusercontent.com/u/7101723?v=4","gravatar_id":"","url":"https://api.github.com/users/BenjiLee","html_url":"https://github.com/BenjiLee","followers_url":"https://api.github.com/users/BenjiLee/followers","following_url":"https://api.github.com/users/BenjiLee/following{/other_user}","gists_url":"https://api.github.com/users/BenjiLee/gists{/gist_id}","starred_url":"https://api.github.com/users/BenjiLee/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BenjiLee/subscriptions","organizations_url":"https://api.github.com/users/BenjiLee/orgs","repos_url":"https://api.github.com/users/BenjiLee/repos","events_url":"https://api.github.com/users/BenjiLee/events{/privacy}","received_events_url":"https://api.github.com/users/BenjiLee/received_events","type":"User","site_admin":false},"body":"@edx/learner-heart \r\n\r\nPhase 1 (https://openedx.atlassian.net/browse/LEARNER-2615) of https://openedx.atlassian.net/browse/LEARNER-2314\r\n\r\n1. Add django-parler to requirements\r\n2. Install Django-parler (this step may be different since we configure prod in a different repo)\r\n3. Create migration to add translations table for subjects\r\n4. Copy data to new table.\r\n5. Modify api to look up and return new fields without changing the response structure\r\n6. Update admin interface to make the unused fields to be uneditable. \r\n\r\nAccessing the subjects list with the query parameter \"language\" will get you the language or default. \r\n\r\nLanguage available: 'en', 'es'\r\nDefault: 'en'\r\n\r\n http://localhost:18381/api/v1/subjects/?language=es Returns es\r\n http://localhost:18381/api/v1/subjects/ Returns default en\r\n http://localhost:18381/api/v1/subjects/?language=es-419 return es\r\n http://localhost:18381/api/v1/subjects/?language=not-a-language returns en","created_at":"2017-09-20T17:30:26Z","updated_at":"2017-09-21T20:43:05Z","closed_at":null,"merged_at":null,"merge_commit_sha":"48c30f821b9c52feb043a642615cdb7acf95c82e","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/edx/course-discovery/pulls/1129/commits","review_comments_url":"https://api.github.com/repos/edx/course-discovery/pulls/1129/comments","review_comment_url":"https://api.github.com/repos/edx/course-discovery/pulls/comments{/number}","comments_url":"https://api.github.com/repos/edx/course-discovery/issues/1129/comments","statuses_url":"https://api.github.com/repos/edx/course-discovery/statuses/e66489c2c932bbaac42823dbef93718e8320eb93","head":{"label":"edx:clee/manualparler","ref":"clee/manualparler","sha":"e66489c2c932bbaac42823dbef93718e8320eb93","user":{"login":"edx","id":3179841,"avatar_url":"https://avatars3.githubusercontent.com/u/3179841?v=4","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":45866355,"name":"course-discovery","full_name":"edx/course-discovery","owner":{"login":"edx","id":3179841,"avatar_url":"https://avatars3.githubusercontent.com/u/3179841?v=4","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/course-discovery","description":"Service providing access to consolidated course and program metadata","fork":false,"url":"https://api.github.com/repos/edx/course-discovery","forks_url":"https://api.github.com/repos/edx/course-discovery/forks","keys_url":"https://api.github.com/repos/edx/course-discovery/keys{/key_id}","collaborators_url":"https://api.github.com/repos/edx/course-discovery/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/edx/course-discovery/teams","hooks_url":"https://api.github.com/repos/edx/course-discovery/hooks","issue_events_url":"https://api.github.com/repos/edx/course-discovery/issues/events{/number}","events_url":"https://api.github.com/repos/edx/course-discovery/events","assignees_url":"https://api.github.com/repos/edx/course-discovery/assignees{/user}","branches_url":"https://api.github.com/repos/edx/course-discovery/branches{/branch}","tags_url":"https://api.github.com/repos/edx/course-discovery/tags","blobs_url":"https://api.github.com/repos/edx/course-discovery/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/edx/course-discovery/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/edx/course-discovery/git/refs{/sha}","trees_url":"https://api.github.com/repos/edx/course-discovery/git/trees{/sha}","statuses_url":"https://api.github.com/repos/edx/course-discovery/statuses/{sha}","languages_url":"https://api.github.com/repos/edx/course-discovery/languages","stargazers_url":"https://api.github.com/repos/edx/course-discovery/stargazers","contributors_url":"https://api.github.com/repos/edx/course-discovery/contributors","subscribers_url":"https://api.github.com/repos/edx/course-discovery/subscribers","subscription_url":"https://api.github.com/repos/edx/course-discovery/subscription","commits_url":"https://api.github.com/repos/edx/course-discovery/commits{/sha}","git_commits_url":"https://api.github.com/repos/edx/course-discovery/git/commits{/sha}","comments_url":"https://api.github.com/repos/edx/course-discovery/comments{/number}","issue_comment_url":"https://api.github.com/repos/edx/course-discovery/issues/comments{/number}","contents_url":"https://api.github.com/repos/edx/course-discovery/contents/{+path}","compare_url":"https://api.github.com/repos/edx/course-discovery/compare/{base}...{head}","merges_url":"https://api.github.com/repos/edx/course-discovery/merges","archive_url":"https://api.github.com/repos/edx/course-discovery/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/edx/course-discovery/downloads","issues_url":"https://api.github.com/repos/edx/course-discovery/issues{/number}","pulls_url":"https://api.github.com/repos/edx/course-discovery/pulls{/number}","milestones_url":"https://api.github.com/repos/edx/course-discovery/milestones{/number}","notifications_url":"https://api.github.com/repos/edx/course-discovery/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/edx/course-discovery/labels{/name}","releases_url":"https://api.github.com/repos/edx/course-discovery/releases{/id}","deployments_url":"https://api.github.com/repos/edx/course-discovery/deployments","created_at":"2015-11-09T20:57:54Z","updated_at":"2017-09-06T00:04:50Z","pushed_at":"2017-09-21T20:16:51Z","git_url":"git://github.com/edx/course-discovery.git","ssh_url":"git@github.com:edx/course-discovery.git","clone_url":"https://github.com/edx/course-discovery.git","svn_url":"https://github.com/edx/course-discovery","homepage":"","size":11198,"stargazers_count":15,"watchers_count":15,"language":"Python","has_issues":false,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":9,"mirror_url":null,"open_issues_count":5,"forks":9,"open_issues":5,"watchers":15,"default_branch":"master"}},"base":{"label":"edx:master","ref":"master","sha":"bc919d8deac79c8ca6fa123ac2a82e1363e5f314","user":{"login":"edx","id":3179841,"avatar_url":"https://avatars3.githubusercontent.com/u/3179841?v=4","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":45866355,"name":"course-discovery","full_name":"edx/course-discovery","owner":{"login":"edx","id":3179841,"avatar_url":"https://avatars3.githubusercontent.com/u/3179841?v=4","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/course-discovery","description":"Service providing access to consolidated course and program metadata","fork":false,"url":"https://api.github.com/repos/edx/course-discovery","forks_url":"https://api.github.com/repos/edx/course-discovery/forks","keys_url":"https://api.github.com/repos/edx/course-discovery/keys{/key_id}","collaborators_url":"https://api.github.com/repos/edx/course-discovery/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/edx/course-discovery/teams","hooks_url":"https://api.github.com/repos/edx/course-discovery/hooks","issue_events_url":"https://api.github.com/repos/edx/course-discovery/issues/events{/number}","events_url":"https://api.github.com/repos/edx/course-discovery/events","assignees_url":"https://api.github.com/repos/edx/course-discovery/assignees{/user}","branches_url":"https://api.github.com/repos/edx/course-discovery/branches{/branch}","tags_url":"https://api.github.com/repos/edx/course-discovery/tags","blobs_url":"https://api.github.com/repos/edx/course-discovery/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/edx/course-discovery/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/edx/course-discovery/git/refs{/sha}","trees_url":"https://api.github.com/repos/edx/course-discovery/git/trees{/sha}","statuses_url":"https://api.github.com/repos/edx/course-discovery/statuses/{sha}","languages_url":"https://api.github.com/repos/edx/course-discovery/languages","stargazers_url":"https://api.github.com/repos/edx/course-discovery/stargazers","contributors_url":"https://api.github.com/repos/edx/course-discovery/contributors","subscribers_url":"https://api.github.com/repos/edx/course-discovery/subscribers","subscription_url":"https://api.github.com/repos/edx/course-discovery/subscription","commits_url":"https://api.github.com/repos/edx/course-discovery/commits{/sha}","git_commits_url":"https://api.github.com/repos/edx/course-discovery/git/commits{/sha}","comments_url":"https://api.github.com/repos/edx/course-discovery/comments{/number}","issue_comment_url":"https://api.github.com/repos/edx/course-discovery/issues/comments{/number}","contents_url":"https://api.github.com/repos/edx/course-discovery/contents/{+path}","compare_url":"https://api.github.com/repos/edx/course-discovery/compare/{base}...{head}","merges_url":"https://api.github.com/repos/edx/course-discovery/merges","archive_url":"https://api.github.com/repos/edx/course-discovery/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/edx/course-discovery/downloads","issues_url":"https://api.github.com/repos/edx/course-discovery/issues{/number}","pulls_url":"https://api.github.com/repos/edx/course-discovery/pulls{/number}","milestones_url":"https://api.github.com/repos/edx/course-discovery/milestones{/number}","notifications_url":"https://api.github.com/repos/edx/course-discovery/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/edx/course-discovery/labels{/name}","releases_url":"https://api.github.com/repos/edx/course-discovery/releases{/id}","deployments_url":"https://api.github.com/repos/edx/course-discovery/deployments","created_at":"2015-11-09T20:57:54Z","updated_at":"2017-09-06T00:04:50Z","pushed_at":"2017-09-21T20:16:51Z","git_url":"git://github.com/edx/course-discovery.git","ssh_url":"git@github.com:edx/course-discovery.git","clone_url":"https://github.com/edx/course-discovery.git","svn_url":"https://github.com/edx/course-discovery","homepage":"","size":11198,"stargazers_count":15,"watchers_count":15,"language":"Python","has_issues":false,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":9,"mirror_url":null,"open_issues_count":5,"forks":9,"open_issues":5,"watchers":15,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/edx/course-discovery/pulls/1129"},"html":{"href":"https://github.com/edx/course-discovery/pull/1129"},"issue":{"href":"https://api.github.com/repos/edx/course-discovery/issues/1129"},"comments":{"href":"https://api.github.com/repos/edx/course-discovery/issues/1129/comments"},"review_comments":{"href":"https://api.github.com/repos/edx/course-discovery/pulls/1129/comments"},"review_comment":{"href":"https://api.github.com/repos/edx/course-discovery/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/edx/course-discovery/pulls/1129/commits"},"statuses":{"href":"https://api.github.com/repos/edx/course-discovery/statuses/e66489c2c932bbaac42823dbef93718e8320eb93"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"amangano-edx"}}