{"action":"created","comment":{"url":"https://api.github.com/repos/cfpb/cfgov-refresh/pulls/comments/39079929","id":39079929,"diff_hunk":"@@ -0,0 +1,46 @@\n+import os\n+\n+from django.views.decorators.http import require_http_methods\n+from django.shortcuts import redirect\n+from django.http import JsonResponse\n+from govdelivery.api import GovDelivery\n+\n+from core.utils import extract_answers_from_request\n+\n+ACCOUNT_CODE = os.environ.get('GOVDELIVERY_ACCOUNT_CODE')\n+REQUIRED_PARAMS = ['email', 'code']\n+\n+\n+@require_http_methods(['POST'])\n+def govdelivery_subscribe(request):\n+    \"\"\"\n+    View that checks to see if the request is AJAX, attempts to subscribe\n+    the user, then either redirects to an error/success page (non-AJAX) or\n+    in the case of AJAX, returns some JSON to tell the front-end.\n+    \"\"\"\n+    is_ajax = request.is_ajax()\n+    if is_ajax:\n+        passing_response = JsonResponse({'result': 'pass'})\n+        failing_response = JsonResponse({'result': 'fail'})\n+    else:\n+        passing_response = redirect('govdelivery:success')\n+        failing_response = redirect('govdelivery:server_error')\n+    for required_param in REQUIRED_PARAMS:\n+        if required_param not in request.POST or not request.POST[required_param]:\n+            return failing_response if is_ajax else \\\n+                redirect('govdelivery:user_error')\n+    email_address = request.POST['email']\n+    codes = request.POST.getlist('code')\n+    gd = GovDelivery(account_code=ACCOUNT_CODE)","path":"cfgov/core/views.py","position":34,"original_position":34,"commit_id":"5a8c2ac63b3eff88db0b567e0eca388ed69efb25","original_commit_id":"5a8c2ac63b3eff88db0b567e0eca388ed69efb25","user":{"login":"anselmbradford","id":704760,"avatar_url":"https://avatars.githubusercontent.com/u/704760?v=3","gravatar_id":"","url":"https://api.github.com/users/anselmbradford","html_url":"https://github.com/anselmbradford","followers_url":"https://api.github.com/users/anselmbradford/followers","following_url":"https://api.github.com/users/anselmbradford/following{/other_user}","gists_url":"https://api.github.com/users/anselmbradford/gists{/gist_id}","starred_url":"https://api.github.com/users/anselmbradford/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/anselmbradford/subscriptions","organizations_url":"https://api.github.com/users/anselmbradford/orgs","repos_url":"https://api.github.com/users/anselmbradford/repos","events_url":"https://api.github.com/users/anselmbradford/events{/privacy}","received_events_url":"https://api.github.com/users/anselmbradford/received_events","type":"User","site_admin":false},"body":"Should `ACCOUNT_CODE` be `GOVDELIVERY_ACCOUNT_CODE` from `.env`?","created_at":"2015-09-09T18:38:31Z","updated_at":"2015-09-09T18:38:31Z","html_url":"https://github.com/cfpb/cfgov-refresh/pull/966#discussion_r39079929","pull_request_url":"https://api.github.com/repos/cfpb/cfgov-refresh/pulls/966","_links":{"self":{"href":"https://api.github.com/repos/cfpb/cfgov-refresh/pulls/comments/39079929"},"html":{"href":"https://github.com/cfpb/cfgov-refresh/pull/966#discussion_r39079929"},"pull_request":{"href":"https://api.github.com/repos/cfpb/cfgov-refresh/pulls/966"}}},"pull_request":{"url":"https://api.github.com/repos/cfpb/cfgov-refresh/pulls/966","id":44581903,"html_url":"https://github.com/cfpb/cfgov-refresh/pull/966","diff_url":"https://github.com/cfpb/cfgov-refresh/pull/966.diff","patch_url":"https://github.com/cfpb/cfgov-refresh/pull/966.patch","issue_url":"https://api.github.com/repos/cfpb/cfgov-refresh/issues/966","number":966,"state":"open","locked":false,"title":"Merged cf-django into cfgov-refresh","user":{"login":"kave","id":254877,"avatar_url":"https://avatars.githubusercontent.com/u/254877?v=3","gravatar_id":"","url":"https://api.github.com/users/kave","html_url":"https://github.com/kave","followers_url":"https://api.github.com/users/kave/followers","following_url":"https://api.github.com/users/kave/following{/other_user}","gists_url":"https://api.github.com/users/kave/gists{/gist_id}","starred_url":"https://api.github.com/users/kave/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kave/subscriptions","organizations_url":"https://api.github.com/users/kave/orgs","repos_url":"https://api.github.com/users/kave/repos","events_url":"https://api.github.com/users/kave/events{/privacy}","received_events_url":"https://api.github.com/users/kave/received_events","type":"User","site_admin":false},"body":"Also updated docs to reflect this change","created_at":"2015-09-09T18:09:28Z","updated_at":"2015-09-09T18:38:31Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b07f6f71bd5546141084a23d3c544911dd43c5f0","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/cfpb/cfgov-refresh/pulls/966/commits","review_comments_url":"https://api.github.com/repos/cfpb/cfgov-refresh/pulls/966/comments","review_comment_url":"https://api.github.com/repos/cfpb/cfgov-refresh/pulls/comments{/number}","comments_url":"https://api.github.com/repos/cfpb/cfgov-refresh/issues/966/comments","statuses_url":"https://api.github.com/repos/cfpb/cfgov-refresh/statuses/5a8c2ac63b3eff88db0b567e0eca388ed69efb25","head":{"label":"kave:merge-django","ref":"merge-django","sha":"5a8c2ac63b3eff88db0b567e0eca388ed69efb25","user":{"login":"kave","id":254877,"avatar_url":"https://avatars.githubusercontent.com/u/254877?v=3","gravatar_id":"","url":"https://api.github.com/users/kave","html_url":"https://github.com/kave","followers_url":"https://api.github.com/users/kave/followers","following_url":"https://api.github.com/users/kave/following{/other_user}","gists_url":"https://api.github.com/users/kave/gists{/gist_id}","starred_url":"https://api.github.com/users/kave/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kave/subscriptions","organizations_url":"https://api.github.com/users/kave/orgs","repos_url":"https://api.github.com/users/kave/repos","events_url":"https://api.github.com/users/kave/events{/privacy}","received_events_url":"https://api.github.com/users/kave/received_events","type":"User","site_admin":false},"repo":{"id":41864821,"name":"cfgov-refresh","full_name":"kave/cfgov-refresh","owner":{"login":"kave","id":254877,"avatar_url":"https://avatars.githubusercontent.com/u/254877?v=3","gravatar_id":"","url":"https://api.github.com/users/kave","html_url":"https://github.com/kave","followers_url":"https://api.github.com/users/kave/followers","following_url":"https://api.github.com/users/kave/following{/other_user}","gists_url":"https://api.github.com/users/kave/gists{/gist_id}","starred_url":"https://api.github.com/users/kave/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kave/subscriptions","organizations_url":"https://api.github.com/users/kave/orgs","repos_url":"https://api.github.com/users/kave/repos","events_url":"https://api.github.com/users/kave/events{/privacy}","received_events_url":"https://api.github.com/users/kave/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/kave/cfgov-refresh","description":"In-progress redesign of the consumerfinance.gov website.","fork":true,"url":"https://api.github.com/repos/kave/cfgov-refresh","forks_url":"https://api.github.com/repos/kave/cfgov-refresh/forks","keys_url":"https://api.github.com/repos/kave/cfgov-refresh/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kave/cfgov-refresh/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kave/cfgov-refresh/teams","hooks_url":"https://api.github.com/repos/kave/cfgov-refresh/hooks","issue_events_url":"https://api.github.com/repos/kave/cfgov-refresh/issues/events{/number}","events_url":"https://api.github.com/repos/kave/cfgov-refresh/events","assignees_url":"https://api.github.com/repos/kave/cfgov-refresh/assignees{/user}","branches_url":"https://api.github.com/repos/kave/cfgov-refresh/branches{/branch}","tags_url":"https://api.github.com/repos/kave/cfgov-refresh/tags","blobs_url":"https://api.github.com/repos/kave/cfgov-refresh/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kave/cfgov-refresh/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kave/cfgov-refresh/git/refs{/sha}","trees_url":"https://api.github.com/repos/kave/cfgov-refresh/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kave/cfgov-refresh/statuses/{sha}","languages_url":"https://api.github.com/repos/kave/cfgov-refresh/languages","stargazers_url":"https://api.github.com/repos/kave/cfgov-refresh/stargazers","contributors_url":"https://api.github.com/repos/kave/cfgov-refresh/contributors","subscribers_url":"https://api.github.com/repos/kave/cfgov-refresh/subscribers","subscription_url":"https://api.github.com/repos/kave/cfgov-refresh/subscription","commits_url":"https://api.github.com/repos/kave/cfgov-refresh/commits{/sha}","git_commits_url":"https://api.github.com/repos/kave/cfgov-refresh/git/commits{/sha}","comments_url":"https://api.github.com/repos/kave/cfgov-refresh/comments{/number}","issue_comment_url":"https://api.github.com/repos/kave/cfgov-refresh/issues/comments{/number}","contents_url":"https://api.github.com/repos/kave/cfgov-refresh/contents/{+path}","compare_url":"https://api.github.com/repos/kave/cfgov-refresh/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kave/cfgov-refresh/merges","archive_url":"https://api.github.com/repos/kave/cfgov-refresh/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kave/cfgov-refresh/downloads","issues_url":"https://api.github.com/repos/kave/cfgov-refresh/issues{/number}","pulls_url":"https://api.github.com/repos/kave/cfgov-refresh/pulls{/number}","milestones_url":"https://api.github.com/repos/kave/cfgov-refresh/milestones{/number}","notifications_url":"https://api.github.com/repos/kave/cfgov-refresh/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kave/cfgov-refresh/labels{/name}","releases_url":"https://api.github.com/repos/kave/cfgov-refresh/releases{/id}","created_at":"2015-09-03T14:37:58Z","updated_at":"2015-09-03T14:37:59Z","pushed_at":"2015-09-09T18:17:42Z","git_url":"git://github.com/kave/cfgov-refresh.git","ssh_url":"git@github.com:kave/cfgov-refresh.git","clone_url":"https://github.com/kave/cfgov-refresh.git","svn_url":"https://github.com/kave/cfgov-refresh","homepage":"","size":88710,"stargazers_count":0,"watchers_count":0,"language":"HTML","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"flapjack"}},"base":{"label":"cfpb:merge-django","ref":"merge-django","sha":"77a0fbc15d753662e8a0bffb3ea65e59c2ff3d84","user":{"login":"cfpb","id":1071563,"avatar_url":"https://avatars.githubusercontent.com/u/1071563?v=3","gravatar_id":"","url":"https://api.github.com/users/cfpb","html_url":"https://github.com/cfpb","followers_url":"https://api.github.com/users/cfpb/followers","following_url":"https://api.github.com/users/cfpb/following{/other_user}","gists_url":"https://api.github.com/users/cfpb/gists{/gist_id}","starred_url":"https://api.github.com/users/cfpb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cfpb/subscriptions","organizations_url":"https://api.github.com/users/cfpb/orgs","repos_url":"https://api.github.com/users/cfpb/repos","events_url":"https://api.github.com/users/cfpb/events{/privacy}","received_events_url":"https://api.github.com/users/cfpb/received_events","type":"Organization","site_admin":false},"repo":{"id":18852566,"name":"cfgov-refresh","full_name":"cfpb/cfgov-refresh","owner":{"login":"cfpb","id":1071563,"avatar_url":"https://avatars.githubusercontent.com/u/1071563?v=3","gravatar_id":"","url":"https://api.github.com/users/cfpb","html_url":"https://github.com/cfpb","followers_url":"https://api.github.com/users/cfpb/followers","following_url":"https://api.github.com/users/cfpb/following{/other_user}","gists_url":"https://api.github.com/users/cfpb/gists{/gist_id}","starred_url":"https://api.github.com/users/cfpb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cfpb/subscriptions","organizations_url":"https://api.github.com/users/cfpb/orgs","repos_url":"https://api.github.com/users/cfpb/repos","events_url":"https://api.github.com/users/cfpb/events{/privacy}","received_events_url":"https://api.github.com/users/cfpb/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/cfpb/cfgov-refresh","description":"In-progress redesign of the consumerfinance.gov website.","fork":false,"url":"https://api.github.com/repos/cfpb/cfgov-refresh","forks_url":"https://api.github.com/repos/cfpb/cfgov-refresh/forks","keys_url":"https://api.github.com/repos/cfpb/cfgov-refresh/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cfpb/cfgov-refresh/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cfpb/cfgov-refresh/teams","hooks_url":"https://api.github.com/repos/cfpb/cfgov-refresh/hooks","issue_events_url":"https://api.github.com/repos/cfpb/cfgov-refresh/issues/events{/number}","events_url":"https://api.github.com/repos/cfpb/cfgov-refresh/events","assignees_url":"https://api.github.com/repos/cfpb/cfgov-refresh/assignees{/user}","branches_url":"https://api.github.com/repos/cfpb/cfgov-refresh/branches{/branch}","tags_url":"https://api.github.com/repos/cfpb/cfgov-refresh/tags","blobs_url":"https://api.github.com/repos/cfpb/cfgov-refresh/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cfpb/cfgov-refresh/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cfpb/cfgov-refresh/git/refs{/sha}","trees_url":"https://api.github.com/repos/cfpb/cfgov-refresh/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cfpb/cfgov-refresh/statuses/{sha}","languages_url":"https://api.github.com/repos/cfpb/cfgov-refresh/languages","stargazers_url":"https://api.github.com/repos/cfpb/cfgov-refresh/stargazers","contributors_url":"https://api.github.com/repos/cfpb/cfgov-refresh/contributors","subscribers_url":"https://api.github.com/repos/cfpb/cfgov-refresh/subscribers","subscription_url":"https://api.github.com/repos/cfpb/cfgov-refresh/subscription","commits_url":"https://api.github.com/repos/cfpb/cfgov-refresh/commits{/sha}","git_commits_url":"https://api.github.com/repos/cfpb/cfgov-refresh/git/commits{/sha}","comments_url":"https://api.github.com/repos/cfpb/cfgov-refresh/comments{/number}","issue_comment_url":"https://api.github.com/repos/cfpb/cfgov-refresh/issues/comments{/number}","contents_url":"https://api.github.com/repos/cfpb/cfgov-refresh/contents/{+path}","compare_url":"https://api.github.com/repos/cfpb/cfgov-refresh/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cfpb/cfgov-refresh/merges","archive_url":"https://api.github.com/repos/cfpb/cfgov-refresh/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cfpb/cfgov-refresh/downloads","issues_url":"https://api.github.com/repos/cfpb/cfgov-refresh/issues{/number}","pulls_url":"https://api.github.com/repos/cfpb/cfgov-refresh/pulls{/number}","milestones_url":"https://api.github.com/repos/cfpb/cfgov-refresh/milestones{/number}","notifications_url":"https://api.github.com/repos/cfpb/cfgov-refresh/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cfpb/cfgov-refresh/labels{/name}","releases_url":"https://api.github.com/repos/cfpb/cfgov-refresh/releases{/id}","created_at":"2014-04-16T19:22:03Z","updated_at":"2015-07-16T17:30:22Z","pushed_at":"2015-09-09T18:17:43Z","git_url":"git://github.com/cfpb/cfgov-refresh.git","ssh_url":"git@github.com:cfpb/cfgov-refresh.git","clone_url":"https://github.com/cfpb/cfgov-refresh.git","svn_url":"https://github.com/cfpb/cfgov-refresh","homepage":"","size":100104,"stargazers_count":9,"watchers_count":9,"language":"HTML","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":18,"mirror_url":null,"open_issues_count":95,"forks":18,"open_issues":95,"watchers":9,"default_branch":"flapjack"}},"_links":{"self":{"href":"https://api.github.com/repos/cfpb/cfgov-refresh/pulls/966"},"html":{"href":"https://github.com/cfpb/cfgov-refresh/pull/966"},"issue":{"href":"https://api.github.com/repos/cfpb/cfgov-refresh/issues/966"},"comments":{"href":"https://api.github.com/repos/cfpb/cfgov-refresh/issues/966/comments"},"review_comments":{"href":"https://api.github.com/repos/cfpb/cfgov-refresh/pulls/966/comments"},"review_comment":{"href":"https://api.github.com/repos/cfpb/cfgov-refresh/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/cfpb/cfgov-refresh/pulls/966/commits"},"statuses":{"href":"https://api.github.com/repos/cfpb/cfgov-refresh/statuses/5a8c2ac63b3eff88db0b567e0eca388ed69efb25"}}}}