GitHub PullRequestReviewCommentEvent at 2014-08-26 03:28:57
Repository: Kawaz3rd
Actor: lambdalisue
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/kawazrepos/Kawaz3rd/pulls/comments/16694220","id":16694220,"diff_hunk":"@@ -0,0 +1,61 @@\n+# coding=utf-8\n+\"\"\"\n+Google Calendar 連携用 Backend\n+`kawaz.core.google.calendar` に依存し settings.GOOGLE_CALENDAR_BACKEND で指定\n+されている\n+\"\"\"\n+__author__ = 'Alisue <lambdalisue@hashnote.net>'\n+from django.conf import settings\n+from django.contrib.sites.models import Site\n+from kawaz.core.gcal.backend import Backend\n+\n+\n+def get_base_url():\n+    cache_name = '_cached_base_url'\n+    if not hasattr(get_base_url, cache_name):\n+        cs = Site.objects.get(pk=settings.SITE_ID)\n+        setattr(get_base_url, cache_name, 'http://{}'.format(cs))\n+    return getattr(get_base_url, cache_name)\n+\n+\n+class KawazGoogleCalendarBackend(Backend):\n+    def translate(self, event):\n+        \"\"\"\n+        Translate kawaz.apps.events.Event to body parameter of Google Calendar\n+        API.\n+        \"\"\"\n+        # translation lambda functions\n+        to_datetime = lambda x: {'dateTime': self.__class__.strftime(x)}\n+        to_visibility = lambda x: 'public' if x == 'public' else 'private'\n+        to_source = lambda x: {'url': get_base_url() + x()}\n+        to_attendees = lambda x: [dict(email=a.email, displayName=a.nickname)\n+                                  for a in x.iterator()]\n+        # translate\n+        translation_table = (\n+            ('summary', 'title', str),\n+            ('description', 'body', str),\n+            ('location', 'place', str),\n+            ('start', 'period_start', to_datetime),\n+            ('end', 'period_end', to_datetime),\n+            ('visibility', 'pub_state', to_visibility),\n+            ('source', 'get_absolute_url', to_source),\n+            ('attendees', 'attendees', to_attendees),\n+        )\n+        return {k: fn(getattr(event, a)) for k, a, fn in translation_table}\n+\n+    def is_valid(self, event, raise_exception=False):\n+        \"\"\"\n+        Check if the specified event is valid for translating to body parameter\n+        of Google Calender API\n+        \"\"\"\n+        if not event.period_start or not event.period_end:","path":"src/kawaz/apps/events/gcal.py","position":51,"original_position":51,"commit_id":"0130a50f90e56e1d4c429167a3385a34c22a675b","original_commit_id":"0130a50f90e56e1d4c429167a3385a34c22a675b","user":{"login":"lambdalisue","id":546312,"avatar_url":"https://avatars.githubusercontent.com/u/546312?v=2","gravatar_id":"2be992d8a8cd8b523ca0b1467e165376","url":"https://api.github.com/users/lambdalisue","html_url":"https://github.com/lambdalisue","followers_url":"https://api.github.com/users/lambdalisue/followers","following_url":"https://api.github.com/users/lambdalisue/following{/other_user}","gists_url":"https://api.github.com/users/lambdalisue/gists{/gist_id}","starred_url":"https://api.github.com/users/lambdalisue/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lambdalisue/subscriptions","organizations_url":"https://api.github.com/users/lambdalisue/orgs","repos_url":"https://api.github.com/users/lambdalisue/repos","events_url":"https://api.github.com/users/lambdalisue/events{/privacy}","received_events_url":"https://api.github.com/users/lambdalisue/received_events","type":"User","site_admin":false},"body":"ドキュメントによると必須じゃんｗ","created_at":"2014-08-26T03:28:57Z","updated_at":"2014-08-26T03:28:57Z","html_url":"https://github.com/kawazrepos/Kawaz3rd/pull/143#discussion_r16694220","pull_request_url":"https://api.github.com/repos/kawazrepos/Kawaz3rd/pulls/143","_links":{"self":{"href":"https://api.github.com/repos/kawazrepos/Kawaz3rd/pulls/comments/16694220"},"html":{"href":"https://github.com/kawazrepos/Kawaz3rd/pull/143#discussion_r16694220"},"pull_request":{"href":"https://api.github.com/repos/kawazrepos/Kawaz3rd/pulls/143"}}},"pull_request":{"url":"https://api.github.com/repos/kawazrepos/Kawaz3rd/pulls/143","id":19098935,"html_url":"https://github.com/kawazrepos/Kawaz3rd/pull/143","diff_url":"https://github.com/kawazrepos/Kawaz3rd/pull/143.diff","patch_url":"https://github.com/kawazrepos/Kawaz3rd/pull/143.patch","issue_url":"https://api.github.com/repos/kawazrepos/Kawaz3rd/issues/143","number":143,"state":"open","locked":false,"title":"Googleカレンダー連携を実装した","user":{"login":"giginet","id":147051,"avatar_url":"https://avatars.githubusercontent.com/u/147051?v=2","gravatar_id":"011714704c4a925e542d426d4cdaa4e3","url":"https://api.github.com/users/giginet","html_url":"https://github.com/giginet","followers_url":"https://api.github.com/users/giginet/followers","following_url":"https://api.github.com/users/giginet/following{/other_user}","gists_url":"https://api.github.com/users/giginet/gists{/gist_id}","starred_url":"https://api.github.com/users/giginet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/giginet/subscriptions","organizations_url":"https://api.github.com/users/giginet/orgs","repos_url":"https://api.github.com/users/giginet/repos","events_url":"https://api.github.com/users/giginet/events{/privacy}","received_events_url":"https://api.github.com/users/giginet/received_events","type":"User","site_admin":false},"body":null,"created_at":"2014-07-30T16:01:04Z","updated_at":"2014-08-26T03:28:57Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c88531a051ef3738a8c4992a41651b985bf92a23","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/kawazrepos/Kawaz3rd/pulls/143/commits","review_comments_url":"https://api.github.com/repos/kawazrepos/Kawaz3rd/pulls/143/comments","review_comment_url":"https://api.github.com/repos/kawazrepos/Kawaz3rd/pulls/comments/{number}","comments_url":"https://api.github.com/repos/kawazrepos/Kawaz3rd/issues/143/comments","statuses_url":"https://api.github.com/repos/kawazrepos/Kawaz3rd/statuses/0130a50f90e56e1d4c429167a3385a34c22a675b","head":{"label":"kawazrepos:gcal","ref":"gcal","sha":"0130a50f90e56e1d4c429167a3385a34c22a675b","user":{"login":"kawazrepos","id":1059063,"avatar_url":"https://avatars.githubusercontent.com/u/1059063?v=2","gravatar_id":"45c95001dc31d5ba50cbfd9b83f3dbd7","url":"https://api.github.com/users/kawazrepos","html_url":"https://github.com/kawazrepos","followers_url":"https://api.github.com/users/kawazrepos/followers","following_url":"https://api.github.com/users/kawazrepos/following{/other_user}","gists_url":"https://api.github.com/users/kawazrepos/gists{/gist_id}","starred_url":"https://api.github.com/users/kawazrepos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kawazrepos/subscriptions","organizations_url":"https://api.github.com/users/kawazrepos/orgs","repos_url":"https://api.github.com/users/kawazrepos/repos","events_url":"https://api.github.com/users/kawazrepos/events{/privacy}","received_events_url":"https://api.github.com/users/kawazrepos/received_events","type":"Organization","site_admin":false},"repo":{"id":18743101,"name":"Kawaz3rd","full_name":"kawazrepos/Kawaz3rd","owner":{"login":"kawazrepos","id":1059063,"avatar_url":"https://avatars.githubusercontent.com/u/1059063?v=2","gravatar_id":"45c95001dc31d5ba50cbfd9b83f3dbd7","url":"https://api.github.com/users/kawazrepos","html_url":"https://github.com/kawazrepos","followers_url":"https://api.github.com/users/kawazrepos/followers","following_url":"https://api.github.com/users/kawazrepos/following{/other_user}","gists_url":"https://api.github.com/users/kawazrepos/gists{/gist_id}","starred_url":"https://api.github.com/users/kawazrepos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kawazrepos/subscriptions","organizations_url":"https://api.github.com/users/kawazrepos/orgs","repos_url":"https://api.github.com/users/kawazrepos/repos","events_url":"https://api.github.com/users/kawazrepos/events{/privacy}","received_events_url":"https://api.github.com/users/kawazrepos/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/kawazrepos/Kawaz3rd","description":"All your game are belong to us","fork":false,"url":"https://api.github.com/repos/kawazrepos/Kawaz3rd","forks_url":"https://api.github.com/repos/kawazrepos/Kawaz3rd/forks","keys_url":"https://api.github.com/repos/kawazrepos/Kawaz3rd/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kawazrepos/Kawaz3rd/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kawazrepos/Kawaz3rd/teams","hooks_url":"https://api.github.com/repos/kawazrepos/Kawaz3rd/hooks","issue_events_url":"https://api.github.com/repos/kawazrepos/Kawaz3rd/issues/events{/number}","events_url":"https://api.github.com/repos/kawazrepos/Kawaz3rd/events","assignees_url":"https://api.github.com/repos/kawazrepos/Kawaz3rd/assignees{/user}","branches_url":"https://api.github.com/repos/kawazrepos/Kawaz3rd/branches{/branch}","tags_url":"https://api.github.com/repos/kawazrepos/Kawaz3rd/tags","blobs_url":"https://api.github.com/repos/kawazrepos/Kawaz3rd/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kawazrepos/Kawaz3rd/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kawazrepos/Kawaz3rd/git/refs{/sha}","trees_url":"https://api.github.com/repos/kawazrepos/Kawaz3rd/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kawazrepos/Kawaz3rd/statuses/{sha}","languages_url":"https://api.github.com/repos/kawazrepos/Kawaz3rd/languages","stargazers_url":"https://api.github.com/repos/kawazrepos/Kawaz3rd/stargazers","contributors_url":"https://api.github.com/repos/kawazrepos/Kawaz3rd/contributors","subscribers_url":"https://api.github.com/repos/kawazrepos/Kawaz3rd/subscribers","subscription_url":"https://api.github.com/repos/kawazrepos/Kawaz3rd/subscription","commits_url":"https://api.github.com/repos/kawazrepos/Kawaz3rd/commits{/sha}","git_commits_url":"https://api.github.com/repos/kawazrepos/Kawaz3rd/git/commits{/sha}","comments_url":"https://api.github.com/repos/kawazrepos/Kawaz3rd/comments{/number}","issue_comment_url":"https://api.github.com/repos/kawazrepos/Kawaz3rd/issues/comments/{number}","contents_url":"https://api.github.com/repos/kawazrepos/Kawaz3rd/contents/{+path}","compare_url":"https://api.github.com/repos/kawazrepos/Kawaz3rd/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kawazrepos/Kawaz3rd/merges","archive_url":"https://api.github.com/repos/kawazrepos/Kawaz3rd/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kawazrepos/Kawaz3rd/downloads","issues_url":"https://api.github.com/repos/kawazrepos/Kawaz3rd/issues{/number}","pulls_url":"https://api.github.com/repos/kawazrepos/Kawaz3rd/pulls{/number}","milestones_url":"https://api.github.com/repos/kawazrepos/Kawaz3rd/milestones{/number}","notifications_url":"https://api.github.com/repos/kawazrepos/Kawaz3rd/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kawazrepos/Kawaz3rd/labels{/name}","releases_url":"https://api.github.com/repos/kawazrepos/Kawaz3rd/releases{/id}","created_at":"2014-04-13T23:57:57Z","updated_at":"2014-07-15T10:49:24Z","pushed_at":"2014-08-25T15:10:41Z","git_url":"git://github.com/kawazrepos/Kawaz3rd.git","ssh_url":"git@github.com:kawazrepos/Kawaz3rd.git","clone_url":"https://github.com/kawazrepos/Kawaz3rd.git","svn_url":"https://github.com/kawazrepos/Kawaz3rd","homepage":null,"size":8826,"stargazers_count":4,"watchers_count":4,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"forks_count":1,"mirror_url":null,"open_issues_count":4,"forks":1,"open_issues":4,"watchers":4,"default_branch":"develop"}},"base":{"label":"kawazrepos:develop","ref":"develop","sha":"66cb712972ac3453933fbed386af7205b435272f","user":{"login":"kawazrepos","id":1059063,"avatar_url":"https://avatars.githubusercontent.com/u/1059063?v=2","gravatar_id":"45c95001dc31d5ba50cbfd9b83f3dbd7","url":"https://api.github.com/users/kawazrepos","html_url":"https://github.com/kawazrepos","followers_url":"https://api.github.com/users/kawazrepos/followers","following_url":"https://api.github.com/users/kawazrepos/following{/other_user}","gists_url":"https://api.github.com/users/kawazrepos/gists{/gist_id}","starred_url":"https://api.github.com/users/kawazrepos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kawazrepos/subscriptions","organizations_url":"https://api.github.com/users/kawazrepos/orgs","repos_url":"https://api.github.com/users/kawazrepos/repos","events_url":"https://api.github.com/users/kawazrepos/events{/privacy}","received_events_url":"https://api.github.com/users/kawazrepos/received_events","type":"Organization","site_admin":false},"repo":{"id":18743101,"name":"Kawaz3rd","full_name":"kawazrepos/Kawaz3rd","owner":{"login":"kawazrepos","id":1059063,"avatar_url":"https://avatars.githubusercontent.com/u/1059063?v=2","gravatar_id":"45c95001dc31d5ba50cbfd9b83f3dbd7","url":"https://api.github.com/users/kawazrepos","html_url":"https://github.com/kawazrepos","followers_url":"https://api.github.com/users/kawazrepos/followers","following_url":"https://api.github.com/users/kawazrepos/following{/other_user}","gists_url":"https://api.github.com/users/kawazrepos/gists{/gist_id}","starred_url":"https://api.github.com/users/kawazrepos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kawazrepos/subscriptions","organizations_url":"https://api.github.com/users/kawazrepos/orgs","repos_url":"https://api.github.com/users/kawazrepos/repos","events_url":"https://api.github.com/users/kawazrepos/events{/privacy}","received_events_url":"https://api.github.com/users/kawazrepos/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/kawazrepos/Kawaz3rd","description":"All your game are belong to us","fork":false,"url":"https://api.github.com/repos/kawazrepos/Kawaz3rd","forks_url":"https://api.github.com/repos/kawazrepos/Kawaz3rd/forks","keys_url":"https://api.github.com/repos/kawazrepos/Kawaz3rd/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kawazrepos/Kawaz3rd/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kawazrepos/Kawaz3rd/teams","hooks_url":"https://api.github.com/repos/kawazrepos/Kawaz3rd/hooks","issue_events_url":"https://api.github.com/repos/kawazrepos/Kawaz3rd/issues/events{/number}","events_url":"https://api.github.com/repos/kawazrepos/Kawaz3rd/events","assignees_url":"https://api.github.com/repos/kawazrepos/Kawaz3rd/assignees{/user}","branches_url":"https://api.github.com/repos/kawazrepos/Kawaz3rd/branches{/branch}","tags_url":"https://api.github.com/repos/kawazrepos/Kawaz3rd/tags","blobs_url":"https://api.github.com/repos/kawazrepos/Kawaz3rd/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kawazrepos/Kawaz3rd/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kawazrepos/Kawaz3rd/git/refs{/sha}","trees_url":"https://api.github.com/repos/kawazrepos/Kawaz3rd/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kawazrepos/Kawaz3rd/statuses/{sha}","languages_url":"https://api.github.com/repos/kawazrepos/Kawaz3rd/languages","stargazers_url":"https://api.github.com/repos/kawazrepos/Kawaz3rd/stargazers","contributors_url":"https://api.github.com/repos/kawazrepos/Kawaz3rd/contributors","subscribers_url":"https://api.github.com/repos/kawazrepos/Kawaz3rd/subscribers","subscription_url":"https://api.github.com/repos/kawazrepos/Kawaz3rd/subscription","commits_url":"https://api.github.com/repos/kawazrepos/Kawaz3rd/commits{/sha}","git_commits_url":"https://api.github.com/repos/kawazrepos/Kawaz3rd/git/commits{/sha}","comments_url":"https://api.github.com/repos/kawazrepos/Kawaz3rd/comments{/number}","issue_comment_url":"https://api.github.com/repos/kawazrepos/Kawaz3rd/issues/comments/{number}","contents_url":"https://api.github.com/repos/kawazrepos/Kawaz3rd/contents/{+path}","compare_url":"https://api.github.com/repos/kawazrepos/Kawaz3rd/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kawazrepos/Kawaz3rd/merges","archive_url":"https://api.github.com/repos/kawazrepos/Kawaz3rd/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kawazrepos/Kawaz3rd/downloads","issues_url":"https://api.github.com/repos/kawazrepos/Kawaz3rd/issues{/number}","pulls_url":"https://api.github.com/repos/kawazrepos/Kawaz3rd/pulls{/number}","milestones_url":"https://api.github.com/repos/kawazrepos/Kawaz3rd/milestones{/number}","notifications_url":"https://api.github.com/repos/kawazrepos/Kawaz3rd/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kawazrepos/Kawaz3rd/labels{/name}","releases_url":"https://api.github.com/repos/kawazrepos/Kawaz3rd/releases{/id}","created_at":"2014-04-13T23:57:57Z","updated_at":"2014-07-15T10:49:24Z","pushed_at":"2014-08-25T15:10:41Z","git_url":"git://github.com/kawazrepos/Kawaz3rd.git","ssh_url":"git@github.com:kawazrepos/Kawaz3rd.git","clone_url":"https://github.com/kawazrepos/Kawaz3rd.git","svn_url":"https://github.com/kawazrepos/Kawaz3rd","homepage":null,"size":8826,"stargazers_count":4,"watchers_count":4,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"forks_count":1,"mirror_url":null,"open_issues_count":4,"forks":1,"open_issues":4,"watchers":4,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/kawazrepos/Kawaz3rd/pulls/143"},"html":{"href":"https://github.com/kawazrepos/Kawaz3rd/pull/143"},"issue":{"href":"https://api.github.com/repos/kawazrepos/Kawaz3rd/issues/143"},"comments":{"href":"https://api.github.com/repos/kawazrepos/Kawaz3rd/issues/143/comments"},"review_comments":{"href":"https://api.github.com/repos/kawazrepos/Kawaz3rd/pulls/143/comments"},"review_comment":{"href":"https://api.github.com/repos/kawazrepos/Kawaz3rd/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/kawazrepos/Kawaz3rd/pulls/143/commits"},"statuses":{"href":"https://api.github.com/repos/kawazrepos/Kawaz3rd/statuses/0130a50f90e56e1d4c429167a3385a34c22a675b"}}}}