{"action":"created","comment":{"url":"https://api.github.com/repos/edx/edx-platform/pulls/comments/56245966","id":56245966,"diff_hunk":"@@ -180,3 +206,60 @@ def _email_url_parser(url_name, extra_param=None):\n     dashboard_url_path = reverse(url_name) + extra_param if extra_param else reverse(url_name)\n     dashboard_link_parts = (\"https\", site_name, dashboard_url_path, '', '', '')\n     return urlparse.urlunparse(dashboard_link_parts)\n+\n+\n+def get_credit_providers_by_course(user, course_key):\n+    \"\"\"Get the course information from ecommerce and parse the data to get providers.\n+\n+    Arguments:\n+        user (User): The user object.\n+        course_key (CourseKey): The identifier for the course.\n+\n+    Returns:\n+        list, containing course providers.\n+    \"\"\"\n+    credit_config = CreditConfig.current()\n+\n+    # Bypass caching for staff users, who may be adding providers and want\n+    # to see them immediately.\n+\n+    providers_data = None\n+    cache_key = None\n+    if credit_config.enabled:\n+        cache_key = '{key_prefix}.{course_key}'.format(\n+            key_prefix=credit_config.CACHE_KEY, course_key=unicode(course_key)\n+        )\n+        providers_data = cache.get(cache_key)\n+\n+    if providers_data is not None:\n+        return providers_data\n+\n+    providers_data = []\n+    try:\n+        response = ecommerce_api_client(user).courses(unicode(course_key) + '/?include_products=1').get()\n+    except Exception:  # pylint: disable=broad-except\n+        log.exception(\"Failed to receive data from the ecommerce course API for Course ID '%s'.\", unicode(course_key))\n+        return\n+\n+    if not response:\n+        log.debug(\"No Course information found from ecommerce API for Course ID '%s'.\", unicode(course_key))\n+        return\n+\n+    for product in response.get('products'):\n+        providers_data.extend(","path":"openedx/core/djangoapps/credit/email_utils.py","position":103,"original_position":103,"commit_id":"bfc3c25b6d71798584402d715084c7c1659a30e4","original_commit_id":"bfc3c25b6d71798584402d715084c7c1659a30e4","user":{"login":"rlucioni","id":969289,"avatar_url":"https://avatars.githubusercontent.com/u/969289?v=3","gravatar_id":"","url":"https://api.github.com/users/rlucioni","html_url":"https://github.com/rlucioni","followers_url":"https://api.github.com/users/rlucioni/followers","following_url":"https://api.github.com/users/rlucioni/following{/other_user}","gists_url":"https://api.github.com/users/rlucioni/gists{/gist_id}","starred_url":"https://api.github.com/users/rlucioni/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rlucioni/subscriptions","organizations_url":"https://api.github.com/users/rlucioni/orgs","repos_url":"https://api.github.com/users/rlucioni/repos","events_url":"https://api.github.com/users/rlucioni/events{/privacy}","received_events_url":"https://api.github.com/users/rlucioni/received_events","type":"User","site_admin":false},"body":"Just use `+=`.","created_at":"2016-03-15T21:41:19Z","updated_at":"2016-03-15T21:41:19Z","html_url":"https://github.com/edx/edx-platform/pull/11759#discussion_r56245966","pull_request_url":"https://api.github.com/repos/edx/edx-platform/pulls/11759","_links":{"self":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/comments/56245966"},"html":{"href":"https://github.com/edx/edx-platform/pull/11759#discussion_r56245966"},"pull_request":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/11759"}}},"pull_request":{"url":"https://api.github.com/repos/edx/edx-platform/pulls/11759","id":61922568,"html_url":"https://github.com/edx/edx-platform/pull/11759","diff_url":"https://github.com/edx/edx-platform/pull/11759.diff","patch_url":"https://github.com/edx/edx-platform/pull/11759.patch","issue_url":"https://api.github.com/repos/edx/edx-platform/issues/11759","number":11759,"state":"open","locked":false,"title":"Add the providers information in the email.","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":"ECOM-2931\r\n**Calling ecommerce service to get the credit providers.**\r\n**Added creditconfig table/migrtion to manage the cache_ttl.**\r\n**Pass the information to the email template (HTML/TEXT).**\r\n\r\nAdding information into the template needs @marcotuts input. Also If api fails to get providers information what to do in that case. Also text email needs to be updated as well.\r\n","created_at":"2016-03-07T14:18:22Z","updated_at":"2016-03-15T21:41:19Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f64c9d1c295aa93993b5bfd05ed1088f927df9a3","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/edx/edx-platform/pulls/11759/commits","review_comments_url":"https://api.github.com/repos/edx/edx-platform/pulls/11759/comments","review_comment_url":"https://api.github.com/repos/edx/edx-platform/pulls/comments{/number}","comments_url":"https://api.github.com/repos/edx/edx-platform/issues/11759/comments","statuses_url":"https://api.github.com/repos/edx/edx-platform/statuses/bfc3c25b6d71798584402d715084c7c1659a30e4","head":{"label":"edx:awais786/ECOM-2931-update-credit-eligible-email","ref":"awais786/ECOM-2931-update-credit-eligible-email","sha":"bfc3c25b6d71798584402d715084c7c1659a30e4","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":10391073,"name":"edx-platform","full_name":"edx/edx-platform","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/edx-platform","description":"The Open edX platform, the software that powers edX!","fork":false,"url":"https://api.github.com/repos/edx/edx-platform","forks_url":"https://api.github.com/repos/edx/edx-platform/forks","keys_url":"https://api.github.com/repos/edx/edx-platform/keys{/key_id}","collaborators_url":"https://api.github.com/repos/edx/edx-platform/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/edx/edx-platform/teams","hooks_url":"https://api.github.com/repos/edx/edx-platform/hooks","issue_events_url":"https://api.github.com/repos/edx/edx-platform/issues/events{/number}","events_url":"https://api.github.com/repos/edx/edx-platform/events","assignees_url":"https://api.github.com/repos/edx/edx-platform/assignees{/user}","branches_url":"https://api.github.com/repos/edx/edx-platform/branches{/branch}","tags_url":"https://api.github.com/repos/edx/edx-platform/tags","blobs_url":"https://api.github.com/repos/edx/edx-platform/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/edx/edx-platform/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/edx/edx-platform/git/refs{/sha}","trees_url":"https://api.github.com/repos/edx/edx-platform/git/trees{/sha}","statuses_url":"https://api.github.com/repos/edx/edx-platform/statuses/{sha}","languages_url":"https://api.github.com/repos/edx/edx-platform/languages","stargazers_url":"https://api.github.com/repos/edx/edx-platform/stargazers","contributors_url":"https://api.github.com/repos/edx/edx-platform/contributors","subscribers_url":"https://api.github.com/repos/edx/edx-platform/subscribers","subscription_url":"https://api.github.com/repos/edx/edx-platform/subscription","commits_url":"https://api.github.com/repos/edx/edx-platform/commits{/sha}","git_commits_url":"https://api.github.com/repos/edx/edx-platform/git/commits{/sha}","comments_url":"https://api.github.com/repos/edx/edx-platform/comments{/number}","issue_comment_url":"https://api.github.com/repos/edx/edx-platform/issues/comments{/number}","contents_url":"https://api.github.com/repos/edx/edx-platform/contents/{+path}","compare_url":"https://api.github.com/repos/edx/edx-platform/compare/{base}...{head}","merges_url":"https://api.github.com/repos/edx/edx-platform/merges","archive_url":"https://api.github.com/repos/edx/edx-platform/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/edx/edx-platform/downloads","issues_url":"https://api.github.com/repos/edx/edx-platform/issues{/number}","pulls_url":"https://api.github.com/repos/edx/edx-platform/pulls{/number}","milestones_url":"https://api.github.com/repos/edx/edx-platform/milestones{/number}","notifications_url":"https://api.github.com/repos/edx/edx-platform/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/edx/edx-platform/labels{/name}","releases_url":"https://api.github.com/repos/edx/edx-platform/releases{/id}","deployments_url":"https://api.github.com/repos/edx/edx-platform/deployments","created_at":"2013-05-30T20:20:38Z","updated_at":"2016-03-15T18:08:12Z","pushed_at":"2016-03-15T21:19:55Z","git_url":"git://github.com/edx/edx-platform.git","ssh_url":"git@github.com:edx/edx-platform.git","clone_url":"https://github.com/edx/edx-platform.git","svn_url":"https://github.com/edx/edx-platform","homepage":"http://open.edx.org/","size":696751,"stargazers_count":2444,"watchers_count":2444,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1485,"mirror_url":null,"open_issues_count":158,"forks":1485,"open_issues":158,"watchers":2444,"default_branch":"master"}},"base":{"label":"edx:master","ref":"master","sha":"a3caac1fcc3ef77a22ef7eed8ff4838ef4e4a82a","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":10391073,"name":"edx-platform","full_name":"edx/edx-platform","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/edx-platform","description":"The Open edX platform, the software that powers edX!","fork":false,"url":"https://api.github.com/repos/edx/edx-platform","forks_url":"https://api.github.com/repos/edx/edx-platform/forks","keys_url":"https://api.github.com/repos/edx/edx-platform/keys{/key_id}","collaborators_url":"https://api.github.com/repos/edx/edx-platform/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/edx/edx-platform/teams","hooks_url":"https://api.github.com/repos/edx/edx-platform/hooks","issue_events_url":"https://api.github.com/repos/edx/edx-platform/issues/events{/number}","events_url":"https://api.github.com/repos/edx/edx-platform/events","assignees_url":"https://api.github.com/repos/edx/edx-platform/assignees{/user}","branches_url":"https://api.github.com/repos/edx/edx-platform/branches{/branch}","tags_url":"https://api.github.com/repos/edx/edx-platform/tags","blobs_url":"https://api.github.com/repos/edx/edx-platform/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/edx/edx-platform/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/edx/edx-platform/git/refs{/sha}","trees_url":"https://api.github.com/repos/edx/edx-platform/git/trees{/sha}","statuses_url":"https://api.github.com/repos/edx/edx-platform/statuses/{sha}","languages_url":"https://api.github.com/repos/edx/edx-platform/languages","stargazers_url":"https://api.github.com/repos/edx/edx-platform/stargazers","contributors_url":"https://api.github.com/repos/edx/edx-platform/contributors","subscribers_url":"https://api.github.com/repos/edx/edx-platform/subscribers","subscription_url":"https://api.github.com/repos/edx/edx-platform/subscription","commits_url":"https://api.github.com/repos/edx/edx-platform/commits{/sha}","git_commits_url":"https://api.github.com/repos/edx/edx-platform/git/commits{/sha}","comments_url":"https://api.github.com/repos/edx/edx-platform/comments{/number}","issue_comment_url":"https://api.github.com/repos/edx/edx-platform/issues/comments{/number}","contents_url":"https://api.github.com/repos/edx/edx-platform/contents/{+path}","compare_url":"https://api.github.com/repos/edx/edx-platform/compare/{base}...{head}","merges_url":"https://api.github.com/repos/edx/edx-platform/merges","archive_url":"https://api.github.com/repos/edx/edx-platform/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/edx/edx-platform/downloads","issues_url":"https://api.github.com/repos/edx/edx-platform/issues{/number}","pulls_url":"https://api.github.com/repos/edx/edx-platform/pulls{/number}","milestones_url":"https://api.github.com/repos/edx/edx-platform/milestones{/number}","notifications_url":"https://api.github.com/repos/edx/edx-platform/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/edx/edx-platform/labels{/name}","releases_url":"https://api.github.com/repos/edx/edx-platform/releases{/id}","deployments_url":"https://api.github.com/repos/edx/edx-platform/deployments","created_at":"2013-05-30T20:20:38Z","updated_at":"2016-03-15T18:08:12Z","pushed_at":"2016-03-15T21:19:55Z","git_url":"git://github.com/edx/edx-platform.git","ssh_url":"git@github.com:edx/edx-platform.git","clone_url":"https://github.com/edx/edx-platform.git","svn_url":"https://github.com/edx/edx-platform","homepage":"http://open.edx.org/","size":696751,"stargazers_count":2444,"watchers_count":2444,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1485,"mirror_url":null,"open_issues_count":158,"forks":1485,"open_issues":158,"watchers":2444,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/11759"},"html":{"href":"https://github.com/edx/edx-platform/pull/11759"},"issue":{"href":"https://api.github.com/repos/edx/edx-platform/issues/11759"},"comments":{"href":"https://api.github.com/repos/edx/edx-platform/issues/11759/comments"},"review_comments":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/11759/comments"},"review_comment":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/11759/commits"},"statuses":{"href":"https://api.github.com/repos/edx/edx-platform/statuses/bfc3c25b6d71798584402d715084c7c1659a30e4"}}}}