{"action":"created","comment":{"url":"https://api.github.com/repos/andela/ah-orcas/pulls/comments/233972010","pull_request_review_id":175510489,"id":233972010,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIzMzk3MjAxMA==","diff_hunk":"@@ -29,6 +35,68 @@\n LOOKUP_FIELD = 'slug'\n \n \n+def send_followers_notification(instance, Article, request, user):\n+    \"\"\"\n+    send email to user following the author\n+    \"\"\"\n+    try:\n+        profile = UserProfile.objects.get(user=user)\n+        followers = Follow.objects.filter(follower=profile)\n+        article = Article.objects.get(title=instance[\"title\"])\n+        for follower in followers:\n+            message = article.user.username + \" published new article \"\n+            link = DEFAULT_DOMAIN + '/api/article/detail/' + \\\n+                article.slug\n+            follower_message = render_to_string('followee_alert.html', {\n+                'user': follower.followee.user.username,\n+                \"link\": link,\n+                \"message\": message,\n+                \"title\": instance[\"title\"]\n+            })\n+            send_mail('Authors Heaven New Article!',\n+                      'New Article!!!!',\n+                      EMAIL_HOST_USER,\n+                      [follower.followee.user.email],\n+                      html_message=follower_message,\n+                      fail_silently=False)\n+            NotificationsFollower(\n+                follower=profile,\n+                followee=follower.followee,\n+                article=article).save()\n+    except Exception as error:\n+        print(str(error))\n+\n+\n+def send_article_notification(slug, Article,data, request):","path":"authors/apps/article/views.py","position":58,"original_position":58,"commit_id":"149e44cc149cc41096820bc24e85e8fc6354b075","original_commit_id":"149e44cc149cc41096820bc24e85e8fc6354b075","user":{"login":"houndci-bot","id":6697940,"node_id":"MDQ6VXNlcjY2OTc5NDA=","avatar_url":"https://avatars0.githubusercontent.com/u/6697940?v=4","gravatar_id":"","url":"https://api.github.com/users/houndci-bot","html_url":"https://github.com/houndci-bot","followers_url":"https://api.github.com/users/houndci-bot/followers","following_url":"https://api.github.com/users/houndci-bot/following{/other_user}","gists_url":"https://api.github.com/users/houndci-bot/gists{/gist_id}","starred_url":"https://api.github.com/users/houndci-bot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/houndci-bot/subscriptions","organizations_url":"https://api.github.com/users/houndci-bot/orgs","repos_url":"https://api.github.com/users/houndci-bot/repos","events_url":"https://api.github.com/users/houndci-bot/events{/privacy}","received_events_url":"https://api.github.com/users/houndci-bot/received_events","type":"User","site_admin":false},"body":"missing whitespace after ','","created_at":"2018-11-15T19:09:44Z","updated_at":"2018-11-15T19:09:44Z","html_url":"https://github.com/andela/ah-orcas/pull/42#discussion_r233972010","pull_request_url":"https://api.github.com/repos/andela/ah-orcas/pulls/42","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/andela/ah-orcas/pulls/comments/233972010"},"html":{"href":"https://github.com/andela/ah-orcas/pull/42#discussion_r233972010"},"pull_request":{"href":"https://api.github.com/repos/andela/ah-orcas/pulls/42"}}},"pull_request":{"url":"https://api.github.com/repos/andela/ah-orcas/pulls/42","id":231281842,"node_id":"MDExOlB1bGxSZXF1ZXN0MjMxMjgxODQy","html_url":"https://github.com/andela/ah-orcas/pull/42","diff_url":"https://github.com/andela/ah-orcas/pull/42.diff","patch_url":"https://github.com/andela/ah-orcas/pull/42.patch","issue_url":"https://api.github.com/repos/andela/ah-orcas/issues/42","number":42,"state":"open","locked":false,"title":"#161254670 Push notifications","user":{"login":"Gidraf","id":30722290,"node_id":"MDQ6VXNlcjMwNzIyMjkw","avatar_url":"https://avatars3.githubusercontent.com/u/30722290?v=4","gravatar_id":"","url":"https://api.github.com/users/Gidraf","html_url":"https://github.com/Gidraf","followers_url":"https://api.github.com/users/Gidraf/followers","following_url":"https://api.github.com/users/Gidraf/following{/other_user}","gists_url":"https://api.github.com/users/Gidraf/gists{/gist_id}","starred_url":"https://api.github.com/users/Gidraf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Gidraf/subscriptions","organizations_url":"https://api.github.com/users/Gidraf/orgs","repos_url":"https://api.github.com/users/Gidraf/repos","events_url":"https://api.github.com/users/Gidraf/events{/privacy}","received_events_url":"https://api.github.com/users/Gidraf/received_events","type":"User","site_admin":false},"body":"#### What does this PR do?\r\n```Like and dislike an article```\r\n#### Description of Task to be completed?\r\n```This PR enable push notifications: from users they have followed and article they have favourited ```\r\n\r\n#### How should this be manually tested?\r\n- Clone this repo.\r\n``` \r\n$ git clone https://github.com/andela/ah-orcas.git\r\n```\r\n- Navigate to this branch.\r\n``` \r\n$ git clone git checkout  ft-receive-notification-161254670\r\n```\r\n- create a python virtual environment in your local machine and start it.\r\n```code\r\n$ virtualenv env\r\n$ source env/bin/activate\r\n```\r\n- Create a .env file and run it. Check sample.env file to configure yours.\r\n```\r\n$ source .env\r\n```\r\n- Run the app\r\n```\r\n$ python manage.py runserver\r\n```\r\n- Test the endpoint.\r\n\r\n Hit the GET endpoint in the postman\r\n[![Run in Postman](https://run.pstmn.io/button.svg)](https://app.getpostman.com/run-collection/cf46eeb442114295a580)\r\n\r\n#### What are the relevant pivotal tracker stories?\r\n [#161254670](https://www.pivotaltracker.com/story/show/161254670)","created_at":"2018-11-15T17:49:47Z","updated_at":"2018-11-15T19:09:44Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":1103137986,"node_id":"MDU6TGFiZWwxMTAzMTM3OTg2","url":"https://api.github.com/repos/andela/ah-orcas/labels/wip","name":"wip","color":"0f19c6","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/andela/ah-orcas/pulls/42/commits","review_comments_url":"https://api.github.com/repos/andela/ah-orcas/pulls/42/comments","review_comment_url":"https://api.github.com/repos/andela/ah-orcas/pulls/comments{/number}","comments_url":"https://api.github.com/repos/andela/ah-orcas/issues/42/comments","statuses_url":"https://api.github.com/repos/andela/ah-orcas/statuses/149e44cc149cc41096820bc24e85e8fc6354b075","head":{"label":"andela:ft-receive-notification-161254670","ref":"ft-receive-notification-161254670","sha":"149e44cc149cc41096820bc24e85e8fc6354b075","user":{"login":"andela","id":4100206,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQxMDAyMDY=","avatar_url":"https://avatars2.githubusercontent.com/u/4100206?v=4","gravatar_id":"","url":"https://api.github.com/users/andela","html_url":"https://github.com/andela","followers_url":"https://api.github.com/users/andela/followers","following_url":"https://api.github.com/users/andela/following{/other_user}","gists_url":"https://api.github.com/users/andela/gists{/gist_id}","starred_url":"https://api.github.com/users/andela/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andela/subscriptions","organizations_url":"https://api.github.com/users/andela/orgs","repos_url":"https://api.github.com/users/andela/repos","events_url":"https://api.github.com/users/andela/events{/privacy}","received_events_url":"https://api.github.com/users/andela/received_events","type":"Organization","site_admin":false},"repo":{"id":153309142,"node_id":"MDEwOlJlcG9zaXRvcnkxNTMzMDkxNDI=","name":"ah-orcas","full_name":"andela/ah-orcas","private":false,"owner":{"login":"andela","id":4100206,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQxMDAyMDY=","avatar_url":"https://avatars2.githubusercontent.com/u/4100206?v=4","gravatar_id":"","url":"https://api.github.com/users/andela","html_url":"https://github.com/andela","followers_url":"https://api.github.com/users/andela/followers","following_url":"https://api.github.com/users/andela/following{/other_user}","gists_url":"https://api.github.com/users/andela/gists{/gist_id}","starred_url":"https://api.github.com/users/andela/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andela/subscriptions","organizations_url":"https://api.github.com/users/andela/orgs","repos_url":"https://api.github.com/users/andela/repos","events_url":"https://api.github.com/users/andela/events{/privacy}","received_events_url":"https://api.github.com/users/andela/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/andela/ah-orcas","description":null,"fork":false,"url":"https://api.github.com/repos/andela/ah-orcas","forks_url":"https://api.github.com/repos/andela/ah-orcas/forks","keys_url":"https://api.github.com/repos/andela/ah-orcas/keys{/key_id}","collaborators_url":"https://api.github.com/repos/andela/ah-orcas/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/andela/ah-orcas/teams","hooks_url":"https://api.github.com/repos/andela/ah-orcas/hooks","issue_events_url":"https://api.github.com/repos/andela/ah-orcas/issues/events{/number}","events_url":"https://api.github.com/repos/andela/ah-orcas/events","assignees_url":"https://api.github.com/repos/andela/ah-orcas/assignees{/user}","branches_url":"https://api.github.com/repos/andela/ah-orcas/branches{/branch}","tags_url":"https://api.github.com/repos/andela/ah-orcas/tags","blobs_url":"https://api.github.com/repos/andela/ah-orcas/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/andela/ah-orcas/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/andela/ah-orcas/git/refs{/sha}","trees_url":"https://api.github.com/repos/andela/ah-orcas/git/trees{/sha}","statuses_url":"https://api.github.com/repos/andela/ah-orcas/statuses/{sha}","languages_url":"https://api.github.com/repos/andela/ah-orcas/languages","stargazers_url":"https://api.github.com/repos/andela/ah-orcas/stargazers","contributors_url":"https://api.github.com/repos/andela/ah-orcas/contributors","subscribers_url":"https://api.github.com/repos/andela/ah-orcas/subscribers","subscription_url":"https://api.github.com/repos/andela/ah-orcas/subscription","commits_url":"https://api.github.com/repos/andela/ah-orcas/commits{/sha}","git_commits_url":"https://api.github.com/repos/andela/ah-orcas/git/commits{/sha}","comments_url":"https://api.github.com/repos/andela/ah-orcas/comments{/number}","issue_comment_url":"https://api.github.com/repos/andela/ah-orcas/issues/comments{/number}","contents_url":"https://api.github.com/repos/andela/ah-orcas/contents/{+path}","compare_url":"https://api.github.com/repos/andela/ah-orcas/compare/{base}...{head}","merges_url":"https://api.github.com/repos/andela/ah-orcas/merges","archive_url":"https://api.github.com/repos/andela/ah-orcas/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/andela/ah-orcas/downloads","issues_url":"https://api.github.com/repos/andela/ah-orcas/issues{/number}","pulls_url":"https://api.github.com/repos/andela/ah-orcas/pulls{/number}","milestones_url":"https://api.github.com/repos/andela/ah-orcas/milestones{/number}","notifications_url":"https://api.github.com/repos/andela/ah-orcas/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/andela/ah-orcas/labels{/name}","releases_url":"https://api.github.com/repos/andela/ah-orcas/releases{/id}","deployments_url":"https://api.github.com/repos/andela/ah-orcas/deployments","created_at":"2018-10-16T15:27:42Z","updated_at":"2018-11-15T13:36:57Z","pushed_at":"2018-11-15T19:09:27Z","git_url":"git://github.com/andela/ah-orcas.git","ssh_url":"git@github.com:andela/ah-orcas.git","clone_url":"https://github.com/andela/ah-orcas.git","svn_url":"https://github.com/andela/ah-orcas","homepage":null,"size":171,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":1,"license":{"key":"bsd-3-clause","name":"BSD 3-Clause \"New\" or \"Revised\" License","spdx_id":"BSD-3-Clause","url":"https://api.github.com/licenses/bsd-3-clause","node_id":"MDc6TGljZW5zZTU="},"forks":0,"open_issues":1,"watchers":0,"default_branch":"develop"}},"base":{"label":"andela:develop","ref":"develop","sha":"615ace6090d31b9b6a8fb730dcfdd7b1ab47ac98","user":{"login":"andela","id":4100206,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQxMDAyMDY=","avatar_url":"https://avatars2.githubusercontent.com/u/4100206?v=4","gravatar_id":"","url":"https://api.github.com/users/andela","html_url":"https://github.com/andela","followers_url":"https://api.github.com/users/andela/followers","following_url":"https://api.github.com/users/andela/following{/other_user}","gists_url":"https://api.github.com/users/andela/gists{/gist_id}","starred_url":"https://api.github.com/users/andela/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andela/subscriptions","organizations_url":"https://api.github.com/users/andela/orgs","repos_url":"https://api.github.com/users/andela/repos","events_url":"https://api.github.com/users/andela/events{/privacy}","received_events_url":"https://api.github.com/users/andela/received_events","type":"Organization","site_admin":false},"repo":{"id":153309142,"node_id":"MDEwOlJlcG9zaXRvcnkxNTMzMDkxNDI=","name":"ah-orcas","full_name":"andela/ah-orcas","private":false,"owner":{"login":"andela","id":4100206,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQxMDAyMDY=","avatar_url":"https://avatars2.githubusercontent.com/u/4100206?v=4","gravatar_id":"","url":"https://api.github.com/users/andela","html_url":"https://github.com/andela","followers_url":"https://api.github.com/users/andela/followers","following_url":"https://api.github.com/users/andela/following{/other_user}","gists_url":"https://api.github.com/users/andela/gists{/gist_id}","starred_url":"https://api.github.com/users/andela/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andela/subscriptions","organizations_url":"https://api.github.com/users/andela/orgs","repos_url":"https://api.github.com/users/andela/repos","events_url":"https://api.github.com/users/andela/events{/privacy}","received_events_url":"https://api.github.com/users/andela/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/andela/ah-orcas","description":null,"fork":false,"url":"https://api.github.com/repos/andela/ah-orcas","forks_url":"https://api.github.com/repos/andela/ah-orcas/forks","keys_url":"https://api.github.com/repos/andela/ah-orcas/keys{/key_id}","collaborators_url":"https://api.github.com/repos/andela/ah-orcas/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/andela/ah-orcas/teams","hooks_url":"https://api.github.com/repos/andela/ah-orcas/hooks","issue_events_url":"https://api.github.com/repos/andela/ah-orcas/issues/events{/number}","events_url":"https://api.github.com/repos/andela/ah-orcas/events","assignees_url":"https://api.github.com/repos/andela/ah-orcas/assignees{/user}","branches_url":"https://api.github.com/repos/andela/ah-orcas/branches{/branch}","tags_url":"https://api.github.com/repos/andela/ah-orcas/tags","blobs_url":"https://api.github.com/repos/andela/ah-orcas/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/andela/ah-orcas/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/andela/ah-orcas/git/refs{/sha}","trees_url":"https://api.github.com/repos/andela/ah-orcas/git/trees{/sha}","statuses_url":"https://api.github.com/repos/andela/ah-orcas/statuses/{sha}","languages_url":"https://api.github.com/repos/andela/ah-orcas/languages","stargazers_url":"https://api.github.com/repos/andela/ah-orcas/stargazers","contributors_url":"https://api.github.com/repos/andela/ah-orcas/contributors","subscribers_url":"https://api.github.com/repos/andela/ah-orcas/subscribers","subscription_url":"https://api.github.com/repos/andela/ah-orcas/subscription","commits_url":"https://api.github.com/repos/andela/ah-orcas/commits{/sha}","git_commits_url":"https://api.github.com/repos/andela/ah-orcas/git/commits{/sha}","comments_url":"https://api.github.com/repos/andela/ah-orcas/comments{/number}","issue_comment_url":"https://api.github.com/repos/andela/ah-orcas/issues/comments{/number}","contents_url":"https://api.github.com/repos/andela/ah-orcas/contents/{+path}","compare_url":"https://api.github.com/repos/andela/ah-orcas/compare/{base}...{head}","merges_url":"https://api.github.com/repos/andela/ah-orcas/merges","archive_url":"https://api.github.com/repos/andela/ah-orcas/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/andela/ah-orcas/downloads","issues_url":"https://api.github.com/repos/andela/ah-orcas/issues{/number}","pulls_url":"https://api.github.com/repos/andela/ah-orcas/pulls{/number}","milestones_url":"https://api.github.com/repos/andela/ah-orcas/milestones{/number}","notifications_url":"https://api.github.com/repos/andela/ah-orcas/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/andela/ah-orcas/labels{/name}","releases_url":"https://api.github.com/repos/andela/ah-orcas/releases{/id}","deployments_url":"https://api.github.com/repos/andela/ah-orcas/deployments","created_at":"2018-10-16T15:27:42Z","updated_at":"2018-11-15T13:36:57Z","pushed_at":"2018-11-15T19:09:27Z","git_url":"git://github.com/andela/ah-orcas.git","ssh_url":"git@github.com:andela/ah-orcas.git","clone_url":"https://github.com/andela/ah-orcas.git","svn_url":"https://github.com/andela/ah-orcas","homepage":null,"size":171,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":1,"license":{"key":"bsd-3-clause","name":"BSD 3-Clause \"New\" or \"Revised\" License","spdx_id":"BSD-3-Clause","url":"https://api.github.com/licenses/bsd-3-clause","node_id":"MDc6TGljZW5zZTU="},"forks":0,"open_issues":1,"watchers":0,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/andela/ah-orcas/pulls/42"},"html":{"href":"https://github.com/andela/ah-orcas/pull/42"},"issue":{"href":"https://api.github.com/repos/andela/ah-orcas/issues/42"},"comments":{"href":"https://api.github.com/repos/andela/ah-orcas/issues/42/comments"},"review_comments":{"href":"https://api.github.com/repos/andela/ah-orcas/pulls/42/comments"},"review_comment":{"href":"https://api.github.com/repos/andela/ah-orcas/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/andela/ah-orcas/pulls/42/commits"},"statuses":{"href":"https://api.github.com/repos/andela/ah-orcas/statuses/149e44cc149cc41096820bc24e85e8fc6354b075"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"houndci-bot"}}