{"action":"created","comment":{"url":"https://api.github.com/repos/hangpark/mapping/pulls/comments/126376857","pull_request_review_id":48853310,"id":126376857,"diff_hunk":"@@ -0,0 +1,64 @@\n+from django.db import models\n+from django.db.models import Q\n+from django.contrib.auth.models import User\n+\n+\n+def get_friends(user):\n+    if user.is_authenticated():\n+        try:\n+            profile = user.userprofile\n+        except:\n+            profile = UserProfile(user=user)\n+            profile.save()\n+            profile.friends.add(user)\n+        return profile.friends.all()\n+    return User.objects.none()\n+\n+\n+class UserProfile(models.Model):\n+    user = models.OneToOneField(User, null=False)\n+    friends = models.ManyToManyField(User, related_name='friends')\n+\n+    def __str__(self):\n+        return self.user.username\n+\n+\n+def user_directory_path(instance, filename):\n+    return 'user_{user_id}/{filename}'.format(user_id=instance.user_id, filename=filename)\n+\n+\n+class PhotoQuerySet(models.QuerySet):\n+    def accessible_for(self, user):\n+        q = Q(is_public=True)\n+        q |= Q(user__in=get_friends(user))\n+        return self.filter(q).distinct()\n+\n+    def filter_friends(self, user):\n+        return self.filter(user__in=self.get_friends(user))","path":"server/mapping/models.py","position":37,"original_position":37,"commit_id":"2132de0eb3447a31a57c0d0ffc0097365a55272a","original_commit_id":"2132de0eb3447a31a57c0d0ffc0097365a55272a","user":{"login":"JOYN28","id":29791719,"avatar_url":"https://avatars3.githubusercontent.com/u/29791719?v=3","gravatar_id":"","url":"https://api.github.com/users/JOYN28","html_url":"https://github.com/JOYN28","followers_url":"https://api.github.com/users/JOYN28/followers","following_url":"https://api.github.com/users/JOYN28/following{/other_user}","gists_url":"https://api.github.com/users/JOYN28/gists{/gist_id}","starred_url":"https://api.github.com/users/JOYN28/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JOYN28/subscriptions","organizations_url":"https://api.github.com/users/JOYN28/orgs","repos_url":"https://api.github.com/users/JOYN28/repos","events_url":"https://api.github.com/users/JOYN28/events{/privacy}","received_events_url":"https://api.github.com/users/JOYN28/received_events","type":"User","site_admin":false},"body":"Remove `self` in `user__in=self.get_friends(user)`.","created_at":"2017-07-10T09:44:23Z","updated_at":"2017-07-10T09:57:12Z","html_url":"https://github.com/hangpark/mapping/pull/2#discussion_r126376857","pull_request_url":"https://api.github.com/repos/hangpark/mapping/pulls/2","_links":{"self":{"href":"https://api.github.com/repos/hangpark/mapping/pulls/comments/126376857"},"html":{"href":"https://github.com/hangpark/mapping/pull/2#discussion_r126376857"},"pull_request":{"href":"https://api.github.com/repos/hangpark/mapping/pulls/2"}}},"pull_request":{"url":"https://api.github.com/repos/hangpark/mapping/pulls/2","id":129636131,"html_url":"https://github.com/hangpark/mapping/pull/2","diff_url":"https://github.com/hangpark/mapping/pull/2.diff","patch_url":"https://github.com/hangpark/mapping/pull/2.patch","issue_url":"https://api.github.com/repos/hangpark/mapping/issues/2","number":2,"state":"open","locked":false,"title":"[#1] Implement basic API","user":{"login":"hangpark","id":13899323,"avatar_url":"https://avatars3.githubusercontent.com/u/13899323?v=3","gravatar_id":"","url":"https://api.github.com/users/hangpark","html_url":"https://github.com/hangpark","followers_url":"https://api.github.com/users/hangpark/followers","following_url":"https://api.github.com/users/hangpark/following{/other_user}","gists_url":"https://api.github.com/users/hangpark/gists{/gist_id}","starred_url":"https://api.github.com/users/hangpark/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hangpark/subscriptions","organizations_url":"https://api.github.com/users/hangpark/orgs","repos_url":"https://api.github.com/users/hangpark/repos","events_url":"https://api.github.com/users/hangpark/events{/privacy}","received_events_url":"https://api.github.com/users/hangpark/received_events","type":"User","site_admin":false},"body":"See #1","created_at":"2017-07-10T09:30:19Z","updated_at":"2017-07-10T09:57:12Z","closed_at":null,"merged_at":null,"merge_commit_sha":"51d4013968f1856eae1c4edb46da40cc76112cfe","assignee":{"login":"hangpark","id":13899323,"avatar_url":"https://avatars3.githubusercontent.com/u/13899323?v=3","gravatar_id":"","url":"https://api.github.com/users/hangpark","html_url":"https://github.com/hangpark","followers_url":"https://api.github.com/users/hangpark/followers","following_url":"https://api.github.com/users/hangpark/following{/other_user}","gists_url":"https://api.github.com/users/hangpark/gists{/gist_id}","starred_url":"https://api.github.com/users/hangpark/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hangpark/subscriptions","organizations_url":"https://api.github.com/users/hangpark/orgs","repos_url":"https://api.github.com/users/hangpark/repos","events_url":"https://api.github.com/users/hangpark/events{/privacy}","received_events_url":"https://api.github.com/users/hangpark/received_events","type":"User","site_admin":false},"assignees":[{"login":"hangpark","id":13899323,"avatar_url":"https://avatars3.githubusercontent.com/u/13899323?v=3","gravatar_id":"","url":"https://api.github.com/users/hangpark","html_url":"https://github.com/hangpark","followers_url":"https://api.github.com/users/hangpark/followers","following_url":"https://api.github.com/users/hangpark/following{/other_user}","gists_url":"https://api.github.com/users/hangpark/gists{/gist_id}","starred_url":"https://api.github.com/users/hangpark/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hangpark/subscriptions","organizations_url":"https://api.github.com/users/hangpark/orgs","repos_url":"https://api.github.com/users/hangpark/repos","events_url":"https://api.github.com/users/hangpark/events{/privacy}","received_events_url":"https://api.github.com/users/hangpark/received_events","type":"User","site_admin":false}],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/hangpark/mapping/pulls/2/commits","review_comments_url":"https://api.github.com/repos/hangpark/mapping/pulls/2/comments","review_comment_url":"https://api.github.com/repos/hangpark/mapping/pulls/comments{/number}","comments_url":"https://api.github.com/repos/hangpark/mapping/issues/2/comments","statuses_url":"https://api.github.com/repos/hangpark/mapping/statuses/2132de0eb3447a31a57c0d0ffc0097365a55272a","head":{"label":"hangpark:feature/1","ref":"feature/1","sha":"2132de0eb3447a31a57c0d0ffc0097365a55272a","user":{"login":"hangpark","id":13899323,"avatar_url":"https://avatars3.githubusercontent.com/u/13899323?v=3","gravatar_id":"","url":"https://api.github.com/users/hangpark","html_url":"https://github.com/hangpark","followers_url":"https://api.github.com/users/hangpark/followers","following_url":"https://api.github.com/users/hangpark/following{/other_user}","gists_url":"https://api.github.com/users/hangpark/gists{/gist_id}","starred_url":"https://api.github.com/users/hangpark/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hangpark/subscriptions","organizations_url":"https://api.github.com/users/hangpark/orgs","repos_url":"https://api.github.com/users/hangpark/repos","events_url":"https://api.github.com/users/hangpark/events{/privacy}","received_events_url":"https://api.github.com/users/hangpark/received_events","type":"User","site_admin":false},"repo":{"id":96426441,"name":"mapping","full_name":"hangpark/mapping","owner":{"login":"hangpark","id":13899323,"avatar_url":"https://avatars3.githubusercontent.com/u/13899323?v=3","gravatar_id":"","url":"https://api.github.com/users/hangpark","html_url":"https://github.com/hangpark","followers_url":"https://api.github.com/users/hangpark/followers","following_url":"https://api.github.com/users/hangpark/following{/other_user}","gists_url":"https://api.github.com/users/hangpark/gists{/gist_id}","starred_url":"https://api.github.com/users/hangpark/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hangpark/subscriptions","organizations_url":"https://api.github.com/users/hangpark/orgs","repos_url":"https://api.github.com/users/hangpark/repos","events_url":"https://api.github.com/users/hangpark/events{/privacy}","received_events_url":"https://api.github.com/users/hangpark/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/hangpark/mapping","description":"SNS based on photo + map","fork":false,"url":"https://api.github.com/repos/hangpark/mapping","forks_url":"https://api.github.com/repos/hangpark/mapping/forks","keys_url":"https://api.github.com/repos/hangpark/mapping/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hangpark/mapping/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hangpark/mapping/teams","hooks_url":"https://api.github.com/repos/hangpark/mapping/hooks","issue_events_url":"https://api.github.com/repos/hangpark/mapping/issues/events{/number}","events_url":"https://api.github.com/repos/hangpark/mapping/events","assignees_url":"https://api.github.com/repos/hangpark/mapping/assignees{/user}","branches_url":"https://api.github.com/repos/hangpark/mapping/branches{/branch}","tags_url":"https://api.github.com/repos/hangpark/mapping/tags","blobs_url":"https://api.github.com/repos/hangpark/mapping/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hangpark/mapping/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hangpark/mapping/git/refs{/sha}","trees_url":"https://api.github.com/repos/hangpark/mapping/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hangpark/mapping/statuses/{sha}","languages_url":"https://api.github.com/repos/hangpark/mapping/languages","stargazers_url":"https://api.github.com/repos/hangpark/mapping/stargazers","contributors_url":"https://api.github.com/repos/hangpark/mapping/contributors","subscribers_url":"https://api.github.com/repos/hangpark/mapping/subscribers","subscription_url":"https://api.github.com/repos/hangpark/mapping/subscription","commits_url":"https://api.github.com/repos/hangpark/mapping/commits{/sha}","git_commits_url":"https://api.github.com/repos/hangpark/mapping/git/commits{/sha}","comments_url":"https://api.github.com/repos/hangpark/mapping/comments{/number}","issue_comment_url":"https://api.github.com/repos/hangpark/mapping/issues/comments{/number}","contents_url":"https://api.github.com/repos/hangpark/mapping/contents/{+path}","compare_url":"https://api.github.com/repos/hangpark/mapping/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hangpark/mapping/merges","archive_url":"https://api.github.com/repos/hangpark/mapping/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hangpark/mapping/downloads","issues_url":"https://api.github.com/repos/hangpark/mapping/issues{/number}","pulls_url":"https://api.github.com/repos/hangpark/mapping/pulls{/number}","milestones_url":"https://api.github.com/repos/hangpark/mapping/milestones{/number}","notifications_url":"https://api.github.com/repos/hangpark/mapping/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hangpark/mapping/labels{/name}","releases_url":"https://api.github.com/repos/hangpark/mapping/releases{/id}","deployments_url":"https://api.github.com/repos/hangpark/mapping/deployments","created_at":"2017-07-06T12:12:06Z","updated_at":"2017-07-08T14:29:00Z","pushed_at":"2017-07-10T09:35:07Z","git_url":"git://github.com/hangpark/mapping.git","ssh_url":"git@github.com:hangpark/mapping.git","clone_url":"https://github.com/hangpark/mapping.git","svn_url":"https://github.com/hangpark/mapping","homepage":null,"size":1830,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":1,"default_branch":"develop"}},"base":{"label":"hangpark:develop","ref":"develop","sha":"410bfa1f5c931ad70fcee423aa57b5927830e248","user":{"login":"hangpark","id":13899323,"avatar_url":"https://avatars3.githubusercontent.com/u/13899323?v=3","gravatar_id":"","url":"https://api.github.com/users/hangpark","html_url":"https://github.com/hangpark","followers_url":"https://api.github.com/users/hangpark/followers","following_url":"https://api.github.com/users/hangpark/following{/other_user}","gists_url":"https://api.github.com/users/hangpark/gists{/gist_id}","starred_url":"https://api.github.com/users/hangpark/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hangpark/subscriptions","organizations_url":"https://api.github.com/users/hangpark/orgs","repos_url":"https://api.github.com/users/hangpark/repos","events_url":"https://api.github.com/users/hangpark/events{/privacy}","received_events_url":"https://api.github.com/users/hangpark/received_events","type":"User","site_admin":false},"repo":{"id":96426441,"name":"mapping","full_name":"hangpark/mapping","owner":{"login":"hangpark","id":13899323,"avatar_url":"https://avatars3.githubusercontent.com/u/13899323?v=3","gravatar_id":"","url":"https://api.github.com/users/hangpark","html_url":"https://github.com/hangpark","followers_url":"https://api.github.com/users/hangpark/followers","following_url":"https://api.github.com/users/hangpark/following{/other_user}","gists_url":"https://api.github.com/users/hangpark/gists{/gist_id}","starred_url":"https://api.github.com/users/hangpark/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hangpark/subscriptions","organizations_url":"https://api.github.com/users/hangpark/orgs","repos_url":"https://api.github.com/users/hangpark/repos","events_url":"https://api.github.com/users/hangpark/events{/privacy}","received_events_url":"https://api.github.com/users/hangpark/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/hangpark/mapping","description":"SNS based on photo + map","fork":false,"url":"https://api.github.com/repos/hangpark/mapping","forks_url":"https://api.github.com/repos/hangpark/mapping/forks","keys_url":"https://api.github.com/repos/hangpark/mapping/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hangpark/mapping/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hangpark/mapping/teams","hooks_url":"https://api.github.com/repos/hangpark/mapping/hooks","issue_events_url":"https://api.github.com/repos/hangpark/mapping/issues/events{/number}","events_url":"https://api.github.com/repos/hangpark/mapping/events","assignees_url":"https://api.github.com/repos/hangpark/mapping/assignees{/user}","branches_url":"https://api.github.com/repos/hangpark/mapping/branches{/branch}","tags_url":"https://api.github.com/repos/hangpark/mapping/tags","blobs_url":"https://api.github.com/repos/hangpark/mapping/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hangpark/mapping/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hangpark/mapping/git/refs{/sha}","trees_url":"https://api.github.com/repos/hangpark/mapping/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hangpark/mapping/statuses/{sha}","languages_url":"https://api.github.com/repos/hangpark/mapping/languages","stargazers_url":"https://api.github.com/repos/hangpark/mapping/stargazers","contributors_url":"https://api.github.com/repos/hangpark/mapping/contributors","subscribers_url":"https://api.github.com/repos/hangpark/mapping/subscribers","subscription_url":"https://api.github.com/repos/hangpark/mapping/subscription","commits_url":"https://api.github.com/repos/hangpark/mapping/commits{/sha}","git_commits_url":"https://api.github.com/repos/hangpark/mapping/git/commits{/sha}","comments_url":"https://api.github.com/repos/hangpark/mapping/comments{/number}","issue_comment_url":"https://api.github.com/repos/hangpark/mapping/issues/comments{/number}","contents_url":"https://api.github.com/repos/hangpark/mapping/contents/{+path}","compare_url":"https://api.github.com/repos/hangpark/mapping/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hangpark/mapping/merges","archive_url":"https://api.github.com/repos/hangpark/mapping/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hangpark/mapping/downloads","issues_url":"https://api.github.com/repos/hangpark/mapping/issues{/number}","pulls_url":"https://api.github.com/repos/hangpark/mapping/pulls{/number}","milestones_url":"https://api.github.com/repos/hangpark/mapping/milestones{/number}","notifications_url":"https://api.github.com/repos/hangpark/mapping/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hangpark/mapping/labels{/name}","releases_url":"https://api.github.com/repos/hangpark/mapping/releases{/id}","deployments_url":"https://api.github.com/repos/hangpark/mapping/deployments","created_at":"2017-07-06T12:12:06Z","updated_at":"2017-07-08T14:29:00Z","pushed_at":"2017-07-10T09:35:07Z","git_url":"git://github.com/hangpark/mapping.git","ssh_url":"git@github.com:hangpark/mapping.git","clone_url":"https://github.com/hangpark/mapping.git","svn_url":"https://github.com/hangpark/mapping","homepage":null,"size":1830,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":1,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/hangpark/mapping/pulls/2"},"html":{"href":"https://github.com/hangpark/mapping/pull/2"},"issue":{"href":"https://api.github.com/repos/hangpark/mapping/issues/2"},"comments":{"href":"https://api.github.com/repos/hangpark/mapping/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/hangpark/mapping/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/hangpark/mapping/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/hangpark/mapping/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/hangpark/mapping/statuses/2132de0eb3447a31a57c0d0ffc0097365a55272a"}}}}
{"actor":{"display_login":"JOYN28"}}