{"action":"created","comment":{"url":"https://api.github.com/repos/mitodl/micromasters/pulls/comments/67745153","id":67745153,"diff_hunk":"@@ -47,6 +59,127 @@ def test_cant_edit_if_not_owner(self):\n         other_user = UserFactory.create()\n         for method in ('POST', 'PATCH', 'PUT'):\n             with mute_signals(post_save):\n-                profile = ProfileFactory.create()\n+                profile = ProfileFactory.create(account_privacy=Profile.PUBLIC_TO_MM)\n+\n             request = Mock(method=method, user=other_user)\n             assert not perm.has_object_permission(request, None, profile)\n+\n+\n+# pylint: disable=no-self-use\n+class CanSeeIfNotPrivateTests(TestCase):\n+    \"\"\"\n+    Tests for CanEditIfPrivate permissions\n+    \"\"\"\n+\n+    def setUp(self):\n+        super(CanSeeIfNotPrivateTests, self).setUp()\n+        with mute_signals(post_save):\n+            self.other_user = other_user = UserFactory.create(username=\"test\")\n+            username = \"{}_edx\".format(other_user.username)\n+            other_user.social_auth.create(\n+                provider=EdxOrgOAuth2.name,\n+                uid=username\n+            )\n+            self.other_user_profile = ProfileFactory.create(user=other_user, verified_micromaster_user=False)\n+\n+    def test_cant_view_if_privacy_is_private(self):\n+        \"\"\"\n+        Users are not supposed to view private profiles.\n+        \"\"\"\n+        perm = CanSeeIfNotPrivate()\n+\n+        for method in ('POST', 'PATCH', 'PUT'):\n+            with mute_signals(post_save):\n+                profile_private = ProfileFactory.create(account_privacy=Profile.PRIVATE)\n+\n+            request = Mock(method=method, user=self.other_user)\n+            result = Mock(method='get_object_or_404', return_value=profile_private)\n+\n+            with patch('rest_framework.generics._get_object_or_404', result):\n+                view = MagicMock(name='kwargs', return_value={'user': 'test'})","path":"profiles/permissions_test.py","position":73,"original_position":73,"commit_id":"4382db7801af79b322e2659c0dbb167bca97f2e5","original_commit_id":"4382db7801af79b322e2659c0dbb167bca97f2e5","user":{"login":"noisecapella","id":863262,"avatar_url":"https://avatars.githubusercontent.com/u/863262?v=3","gravatar_id":"","url":"https://api.github.com/users/noisecapella","html_url":"https://github.com/noisecapella","followers_url":"https://api.github.com/users/noisecapella/followers","following_url":"https://api.github.com/users/noisecapella/following{/other_user}","gists_url":"https://api.github.com/users/noisecapella/gists{/gist_id}","starred_url":"https://api.github.com/users/noisecapella/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/noisecapella/subscriptions","organizations_url":"https://api.github.com/users/noisecapella/orgs","repos_url":"https://api.github.com/users/noisecapella/repos","events_url":"https://api.github.com/users/noisecapella/events{/privacy}","received_events_url":"https://api.github.com/users/noisecapella/received_events","type":"User","site_admin":false},"body":"Please reference the username from the model here. Either get the username from `self.other_user.social_auth` or store it in a field in the `setUp` method","created_at":"2016-06-20T18:51:21Z","updated_at":"2016-06-20T18:51:21Z","html_url":"https://github.com/mitodl/micromasters/pull/546#discussion_r67745153","pull_request_url":"https://api.github.com/repos/mitodl/micromasters/pulls/546","_links":{"self":{"href":"https://api.github.com/repos/mitodl/micromasters/pulls/comments/67745153"},"html":{"href":"https://github.com/mitodl/micromasters/pull/546#discussion_r67745153"},"pull_request":{"href":"https://api.github.com/repos/mitodl/micromasters/pulls/546"}}},"pull_request":{"url":"https://api.github.com/repos/mitodl/micromasters/pulls/546","id":73904185,"html_url":"https://github.com/mitodl/micromasters/pull/546","diff_url":"https://github.com/mitodl/micromasters/pull/546.diff","patch_url":"https://github.com/mitodl/micromasters/pull/546.patch","issue_url":"https://api.github.com/repos/mitodl/micromasters/issues/546","number":546,"state":"open","locked":false,"title":"Raised 404 from users API for users with privacy setting set to \"private\" ","user":{"login":"amir-qayyum-khan","id":10431250,"avatar_url":"https://avatars.githubusercontent.com/u/10431250?v=3","gravatar_id":"","url":"https://api.github.com/users/amir-qayyum-khan","html_url":"https://github.com/amir-qayyum-khan","followers_url":"https://api.github.com/users/amir-qayyum-khan/followers","following_url":"https://api.github.com/users/amir-qayyum-khan/following{/other_user}","gists_url":"https://api.github.com/users/amir-qayyum-khan/gists{/gist_id}","starred_url":"https://api.github.com/users/amir-qayyum-khan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amir-qayyum-khan/subscriptions","organizations_url":"https://api.github.com/users/amir-qayyum-khan/orgs","repos_url":"https://api.github.com/users/amir-qayyum-khan/repos","events_url":"https://api.github.com/users/amir-qayyum-khan/events{/privacy}","received_events_url":"https://api.github.com/users/amir-qayyum-khan/received_events","type":"User","site_admin":false},"body":"#### What are the relevant tickets?\r\nfixes https://github.com/mitodl/micromasters/issues/483#issuecomment-225736543\r\n\r\n#### What's this PR do?\r\n- Raised 404 exception when user wants to access someones profile whose privacy mode is set tp private\r\n\r\n#### Where should the reviewer start?\r\n- see ```profiles/views.py```\r\n\r\n#### How should this be manually tested?\r\n- Open api for user whose [**account_privacy = private**](http://ip:8079/api/v0/profiles/{user_name}/)\r\n\r\n@pdpinch  @aliceriot  @giocalitri \r\n\r\n#### Screenshots (if appropriate)\r\n\r\n- In case **account_privacy = private**:\r\n<img width=\"867\" alt=\"screen shot 2016-06-15 at 5 35 28 pm\" src=\"https://cloud.githubusercontent.com/assets/10431250/16079983/d31a532a-331f-11e6-9969-577fd6fbfa8e.png\">\r\n\r\n- In case **account_privacy = public_to_mm**:\r\n<img width=\"1189\" alt=\"screen shot 2016-06-15 at 5 38 41 pm\" src=\"https://cloud.githubusercontent.com/assets/10431250/16080023/252a32b6-3320-11e6-81b9-28b35b94fa1c.png\">\r\n\r\n- In case **account_privacy = public**:\r\n<img width=\"1143\" alt=\"screen shot 2016-06-15 at 5 40 33 pm\" src=\"https://cloud.githubusercontent.com/assets/10431250/16080046/4dff7840-3320-11e6-9797-cd971d9205c1.png\">\r\n\r\n\r\n\r\n","created_at":"2016-06-15T12:41:03Z","updated_at":"2016-06-20T18:51:21Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1747bd9f3821ea14d5ad37f75db3849efaf0f16c","assignee":{"login":"giocalitri","id":1005204,"avatar_url":"https://avatars.githubusercontent.com/u/1005204?v=3","gravatar_id":"","url":"https://api.github.com/users/giocalitri","html_url":"https://github.com/giocalitri","followers_url":"https://api.github.com/users/giocalitri/followers","following_url":"https://api.github.com/users/giocalitri/following{/other_user}","gists_url":"https://api.github.com/users/giocalitri/gists{/gist_id}","starred_url":"https://api.github.com/users/giocalitri/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/giocalitri/subscriptions","organizations_url":"https://api.github.com/users/giocalitri/orgs","repos_url":"https://api.github.com/users/giocalitri/repos","events_url":"https://api.github.com/users/giocalitri/events{/privacy}","received_events_url":"https://api.github.com/users/giocalitri/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/mitodl/micromasters/pulls/546/commits","review_comments_url":"https://api.github.com/repos/mitodl/micromasters/pulls/546/comments","review_comment_url":"https://api.github.com/repos/mitodl/micromasters/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mitodl/micromasters/issues/546/comments","statuses_url":"https://api.github.com/repos/mitodl/micromasters/statuses/4382db7801af79b322e2659c0dbb167bca97f2e5","head":{"label":"mitodl:enhance/aq/response_of_private_user_api_#483","ref":"enhance/aq/response_of_private_user_api_#483","sha":"4382db7801af79b322e2659c0dbb167bca97f2e5","user":{"login":"mitodl","id":7918516,"avatar_url":"https://avatars.githubusercontent.com/u/7918516?v=3","gravatar_id":"","url":"https://api.github.com/users/mitodl","html_url":"https://github.com/mitodl","followers_url":"https://api.github.com/users/mitodl/followers","following_url":"https://api.github.com/users/mitodl/following{/other_user}","gists_url":"https://api.github.com/users/mitodl/gists{/gist_id}","starred_url":"https://api.github.com/users/mitodl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mitodl/subscriptions","organizations_url":"https://api.github.com/users/mitodl/orgs","repos_url":"https://api.github.com/users/mitodl/repos","events_url":"https://api.github.com/users/mitodl/events{/privacy}","received_events_url":"https://api.github.com/users/mitodl/received_events","type":"Organization","site_admin":false},"repo":{"id":52919185,"name":"micromasters","full_name":"mitodl/micromasters","owner":{"login":"mitodl","id":7918516,"avatar_url":"https://avatars.githubusercontent.com/u/7918516?v=3","gravatar_id":"","url":"https://api.github.com/users/mitodl","html_url":"https://github.com/mitodl","followers_url":"https://api.github.com/users/mitodl/followers","following_url":"https://api.github.com/users/mitodl/following{/other_user}","gists_url":"https://api.github.com/users/mitodl/gists{/gist_id}","starred_url":"https://api.github.com/users/mitodl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mitodl/subscriptions","organizations_url":"https://api.github.com/users/mitodl/orgs","repos_url":"https://api.github.com/users/mitodl/repos","events_url":"https://api.github.com/users/mitodl/events{/privacy}","received_events_url":"https://api.github.com/users/mitodl/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mitodl/micromasters","description":"Portal for learners and course teams to access MITx micromasters programs: https://goo.gl/tsUTSO","fork":false,"url":"https://api.github.com/repos/mitodl/micromasters","forks_url":"https://api.github.com/repos/mitodl/micromasters/forks","keys_url":"https://api.github.com/repos/mitodl/micromasters/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mitodl/micromasters/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mitodl/micromasters/teams","hooks_url":"https://api.github.com/repos/mitodl/micromasters/hooks","issue_events_url":"https://api.github.com/repos/mitodl/micromasters/issues/events{/number}","events_url":"https://api.github.com/repos/mitodl/micromasters/events","assignees_url":"https://api.github.com/repos/mitodl/micromasters/assignees{/user}","branches_url":"https://api.github.com/repos/mitodl/micromasters/branches{/branch}","tags_url":"https://api.github.com/repos/mitodl/micromasters/tags","blobs_url":"https://api.github.com/repos/mitodl/micromasters/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mitodl/micromasters/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mitodl/micromasters/git/refs{/sha}","trees_url":"https://api.github.com/repos/mitodl/micromasters/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mitodl/micromasters/statuses/{sha}","languages_url":"https://api.github.com/repos/mitodl/micromasters/languages","stargazers_url":"https://api.github.com/repos/mitodl/micromasters/stargazers","contributors_url":"https://api.github.com/repos/mitodl/micromasters/contributors","subscribers_url":"https://api.github.com/repos/mitodl/micromasters/subscribers","subscription_url":"https://api.github.com/repos/mitodl/micromasters/subscription","commits_url":"https://api.github.com/repos/mitodl/micromasters/commits{/sha}","git_commits_url":"https://api.github.com/repos/mitodl/micromasters/git/commits{/sha}","comments_url":"https://api.github.com/repos/mitodl/micromasters/comments{/number}","issue_comment_url":"https://api.github.com/repos/mitodl/micromasters/issues/comments{/number}","contents_url":"https://api.github.com/repos/mitodl/micromasters/contents/{+path}","compare_url":"https://api.github.com/repos/mitodl/micromasters/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mitodl/micromasters/merges","archive_url":"https://api.github.com/repos/mitodl/micromasters/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mitodl/micromasters/downloads","issues_url":"https://api.github.com/repos/mitodl/micromasters/issues{/number}","pulls_url":"https://api.github.com/repos/mitodl/micromasters/pulls{/number}","milestones_url":"https://api.github.com/repos/mitodl/micromasters/milestones{/number}","notifications_url":"https://api.github.com/repos/mitodl/micromasters/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mitodl/micromasters/labels{/name}","releases_url":"https://api.github.com/repos/mitodl/micromasters/releases{/id}","deployments_url":"https://api.github.com/repos/mitodl/micromasters/deployments","created_at":"2016-03-01T23:53:17Z","updated_at":"2016-05-19T04:06:03Z","pushed_at":"2016-06-20T18:08:37Z","git_url":"git://github.com/mitodl/micromasters.git","ssh_url":"git@github.com:mitodl/micromasters.git","clone_url":"https://github.com/mitodl/micromasters.git","svn_url":"https://github.com/mitodl/micromasters","homepage":"","size":10602,"stargazers_count":3,"watchers_count":3,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":102,"forks":0,"open_issues":102,"watchers":3,"default_branch":"master"}},"base":{"label":"mitodl:master","ref":"master","sha":"ff81c29f6ace3dfcffd32ffc24493b082cfa500b","user":{"login":"mitodl","id":7918516,"avatar_url":"https://avatars.githubusercontent.com/u/7918516?v=3","gravatar_id":"","url":"https://api.github.com/users/mitodl","html_url":"https://github.com/mitodl","followers_url":"https://api.github.com/users/mitodl/followers","following_url":"https://api.github.com/users/mitodl/following{/other_user}","gists_url":"https://api.github.com/users/mitodl/gists{/gist_id}","starred_url":"https://api.github.com/users/mitodl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mitodl/subscriptions","organizations_url":"https://api.github.com/users/mitodl/orgs","repos_url":"https://api.github.com/users/mitodl/repos","events_url":"https://api.github.com/users/mitodl/events{/privacy}","received_events_url":"https://api.github.com/users/mitodl/received_events","type":"Organization","site_admin":false},"repo":{"id":52919185,"name":"micromasters","full_name":"mitodl/micromasters","owner":{"login":"mitodl","id":7918516,"avatar_url":"https://avatars.githubusercontent.com/u/7918516?v=3","gravatar_id":"","url":"https://api.github.com/users/mitodl","html_url":"https://github.com/mitodl","followers_url":"https://api.github.com/users/mitodl/followers","following_url":"https://api.github.com/users/mitodl/following{/other_user}","gists_url":"https://api.github.com/users/mitodl/gists{/gist_id}","starred_url":"https://api.github.com/users/mitodl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mitodl/subscriptions","organizations_url":"https://api.github.com/users/mitodl/orgs","repos_url":"https://api.github.com/users/mitodl/repos","events_url":"https://api.github.com/users/mitodl/events{/privacy}","received_events_url":"https://api.github.com/users/mitodl/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mitodl/micromasters","description":"Portal for learners and course teams to access MITx micromasters programs: https://goo.gl/tsUTSO","fork":false,"url":"https://api.github.com/repos/mitodl/micromasters","forks_url":"https://api.github.com/repos/mitodl/micromasters/forks","keys_url":"https://api.github.com/repos/mitodl/micromasters/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mitodl/micromasters/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mitodl/micromasters/teams","hooks_url":"https://api.github.com/repos/mitodl/micromasters/hooks","issue_events_url":"https://api.github.com/repos/mitodl/micromasters/issues/events{/number}","events_url":"https://api.github.com/repos/mitodl/micromasters/events","assignees_url":"https://api.github.com/repos/mitodl/micromasters/assignees{/user}","branches_url":"https://api.github.com/repos/mitodl/micromasters/branches{/branch}","tags_url":"https://api.github.com/repos/mitodl/micromasters/tags","blobs_url":"https://api.github.com/repos/mitodl/micromasters/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mitodl/micromasters/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mitodl/micromasters/git/refs{/sha}","trees_url":"https://api.github.com/repos/mitodl/micromasters/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mitodl/micromasters/statuses/{sha}","languages_url":"https://api.github.com/repos/mitodl/micromasters/languages","stargazers_url":"https://api.github.com/repos/mitodl/micromasters/stargazers","contributors_url":"https://api.github.com/repos/mitodl/micromasters/contributors","subscribers_url":"https://api.github.com/repos/mitodl/micromasters/subscribers","subscription_url":"https://api.github.com/repos/mitodl/micromasters/subscription","commits_url":"https://api.github.com/repos/mitodl/micromasters/commits{/sha}","git_commits_url":"https://api.github.com/repos/mitodl/micromasters/git/commits{/sha}","comments_url":"https://api.github.com/repos/mitodl/micromasters/comments{/number}","issue_comment_url":"https://api.github.com/repos/mitodl/micromasters/issues/comments{/number}","contents_url":"https://api.github.com/repos/mitodl/micromasters/contents/{+path}","compare_url":"https://api.github.com/repos/mitodl/micromasters/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mitodl/micromasters/merges","archive_url":"https://api.github.com/repos/mitodl/micromasters/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mitodl/micromasters/downloads","issues_url":"https://api.github.com/repos/mitodl/micromasters/issues{/number}","pulls_url":"https://api.github.com/repos/mitodl/micromasters/pulls{/number}","milestones_url":"https://api.github.com/repos/mitodl/micromasters/milestones{/number}","notifications_url":"https://api.github.com/repos/mitodl/micromasters/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mitodl/micromasters/labels{/name}","releases_url":"https://api.github.com/repos/mitodl/micromasters/releases{/id}","deployments_url":"https://api.github.com/repos/mitodl/micromasters/deployments","created_at":"2016-03-01T23:53:17Z","updated_at":"2016-05-19T04:06:03Z","pushed_at":"2016-06-20T18:08:37Z","git_url":"git://github.com/mitodl/micromasters.git","ssh_url":"git@github.com:mitodl/micromasters.git","clone_url":"https://github.com/mitodl/micromasters.git","svn_url":"https://github.com/mitodl/micromasters","homepage":"","size":10602,"stargazers_count":3,"watchers_count":3,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":102,"forks":0,"open_issues":102,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mitodl/micromasters/pulls/546"},"html":{"href":"https://github.com/mitodl/micromasters/pull/546"},"issue":{"href":"https://api.github.com/repos/mitodl/micromasters/issues/546"},"comments":{"href":"https://api.github.com/repos/mitodl/micromasters/issues/546/comments"},"review_comments":{"href":"https://api.github.com/repos/mitodl/micromasters/pulls/546/comments"},"review_comment":{"href":"https://api.github.com/repos/mitodl/micromasters/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mitodl/micromasters/pulls/546/commits"},"statuses":{"href":"https://api.github.com/repos/mitodl/micromasters/statuses/4382db7801af79b322e2659c0dbb167bca97f2e5"}}}}
{"actor":{"display_login":"noisecapella"}}