{"action":"created","comment":{"url":"https://api.github.com/repos/ox-it/talks.ox/pulls/comments/36206644","id":36206644,"diff_hunk":"@@ -208,13 +219,64 @@ def save_item(request, collection_id=None):\n \n # TODO: require auth\n @api_view([\"POST\"])\n-def remove_item(request, collection_id=None):\n-    user_collection = request.tuser.default_collection\n+def remove_item(request):\n+    collection = collection_from_request(request)\n     item = item_from_request(request)\n-    deleted = user_collection.remove_item(item)\n+    deleted = collection.remove_item(item)\n     if deleted:\n         serializer = get_item_serializer(item)\n         return Response(serializer.data, status=status.HTTP_200_OK)\n     else:\n         return Response({'error': \"Item not found.\"},\n                         status=status.HTTP_404_NOT_FOUND)\n+\n+# TODO: require auth\n+@api_view([\"POST\"])\n+def subscribe_to_list(request):\n+    collection = collection_from_request(request)\n+    if collection:\n+        TalksUserCollection.objects.get_or_create(user=request.tuser,\n+                                                collection=collection,\n+                                                role=COLLECTION_ROLES_READER)\n+        usercollection = TalksUserCollection.objects.get(user=request.tuser,\n+                                            collection=collection,\n+                                            role=COLLECTION_ROLES_READER)\n+        serializer = TalksUserCollectionSerializer(usercollection)\n+        return Response(serializer.data, status=status.HTTP_200_OK)\n+    else:\n+        return Response({'error': \"Collection not found\"},\n+                        status=status.HTTP_404_NOT_FOUND)\n+\n+\n+# TODO: require auth\n+@api_view([\"POST\"])\n+def unsubscribe_from_list(request):\n+    collection = collection_from_request(request)\n+    usercollection = TalksUserCollection.objects.get(user=request.tuser,\n+                                            collection=collection,\n+                                            role=COLLECTION_ROLES_READER)\n+    if usercollection:\n+        deleted = usercollection.delete()\n+        serializer = TalksUserCollectionSerializer(usercollection)\n+        return Response(serializer.data, status=status.HTTP_200_OK)\n+    else:\n+        return Response({'error': \"Collection not found.\"},\n+                        status=status.HTTP_404_NOT_FOUND)\n+\n+\n+@api_view([\"GET\"])\n+@renderer_classes((ICalRenderer,))\n+def api_collection_ics(request, collection_slug):\n+    \"\"\"Get events and event groups from a collection to be displayed\n+    as an iCal feed\n+    \"\"\"\n+    collection = Collection.objects.get(slug=collection_slug)","path":"talks/api/views.py","position":122,"original_position":122,"commit_id":"5dd28f23505578db2569c86cefa54ec7ce9833b8","original_commit_id":"5dd28f23505578db2569c86cefa54ec7ce9833b8","user":{"login":"ahaith","id":6075037,"avatar_url":"https://avatars.githubusercontent.com/u/6075037?v=3","gravatar_id":"","url":"https://api.github.com/users/ahaith","html_url":"https://github.com/ahaith","followers_url":"https://api.github.com/users/ahaith/followers","following_url":"https://api.github.com/users/ahaith/following{/other_user}","gists_url":"https://api.github.com/users/ahaith/gists{/gist_id}","starred_url":"https://api.github.com/users/ahaith/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ahaith/subscriptions","organizations_url":"https://api.github.com/users/ahaith/orgs","repos_url":"https://api.github.com/users/ahaith/repos","events_url":"https://api.github.com/users/ahaith/events{/privacy}","received_events_url":"https://api.github.com/users/ahaith/received_events","type":"User","site_admin":false},"body":"try/catch in case of ObjectDoesNotExist exception","created_at":"2015-08-04T16:05:43Z","updated_at":"2015-08-04T16:05:43Z","html_url":"https://github.com/ox-it/talks.ox/pull/349#discussion_r36206644","pull_request_url":"https://api.github.com/repos/ox-it/talks.ox/pulls/349","_links":{"self":{"href":"https://api.github.com/repos/ox-it/talks.ox/pulls/comments/36206644"},"html":{"href":"https://github.com/ox-it/talks.ox/pull/349#discussion_r36206644"},"pull_request":{"href":"https://api.github.com/repos/ox-it/talks.ox/pulls/349"}}},"pull_request":{"url":"https://api.github.com/repos/ox-it/talks.ox/pulls/349","id":41479556,"html_url":"https://github.com/ox-it/talks.ox/pull/349","diff_url":"https://github.com/ox-it/talks.ox/pull/349.diff","patch_url":"https://github.com/ox-it/talks.ox/pull/349.patch","issue_url":"https://api.github.com/repos/ox-it/talks.ox/issues/349","number":349,"state":"open","locked":false,"title":"Manage collections","user":{"login":"vladigor","id":11734883,"avatar_url":"https://avatars.githubusercontent.com/u/11734883?v=3","gravatar_id":"","url":"https://api.github.com/users/vladigor","html_url":"https://github.com/vladigor","followers_url":"https://api.github.com/users/vladigor/followers","following_url":"https://api.github.com/users/vladigor/following{/other_user}","gists_url":"https://api.github.com/users/vladigor/gists{/gist_id}","starred_url":"https://api.github.com/users/vladigor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vladigor/subscriptions","organizations_url":"https://api.github.com/users/vladigor/orgs","repos_url":"https://api.github.com/users/vladigor/repos","events_url":"https://api.github.com/users/vladigor/events{/privacy}","received_events_url":"https://api.github.com/users/vladigor/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-08-03T15:35:31Z","updated_at":"2015-08-04T16:05:43Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/ox-it/talks.ox/pulls/349/commits","review_comments_url":"https://api.github.com/repos/ox-it/talks.ox/pulls/349/comments","review_comment_url":"https://api.github.com/repos/ox-it/talks.ox/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ox-it/talks.ox/issues/349/comments","statuses_url":"https://api.github.com/repos/ox-it/talks.ox/statuses/5dd28f23505578db2569c86cefa54ec7ce9833b8","head":{"label":"ox-it:manage_collections","ref":"manage_collections","sha":"5dd28f23505578db2569c86cefa54ec7ce9833b8","user":{"login":"ox-it","id":351950,"avatar_url":"https://avatars.githubusercontent.com/u/351950?v=3","gravatar_id":"","url":"https://api.github.com/users/ox-it","html_url":"https://github.com/ox-it","followers_url":"https://api.github.com/users/ox-it/followers","following_url":"https://api.github.com/users/ox-it/following{/other_user}","gists_url":"https://api.github.com/users/ox-it/gists{/gist_id}","starred_url":"https://api.github.com/users/ox-it/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ox-it/subscriptions","organizations_url":"https://api.github.com/users/ox-it/orgs","repos_url":"https://api.github.com/users/ox-it/repos","events_url":"https://api.github.com/users/ox-it/events{/privacy}","received_events_url":"https://api.github.com/users/ox-it/received_events","type":"Organization","site_admin":false},"repo":{"id":19783550,"name":"talks.ox","full_name":"ox-it/talks.ox","owner":{"login":"ox-it","id":351950,"avatar_url":"https://avatars.githubusercontent.com/u/351950?v=3","gravatar_id":"","url":"https://api.github.com/users/ox-it","html_url":"https://github.com/ox-it","followers_url":"https://api.github.com/users/ox-it/followers","following_url":"https://api.github.com/users/ox-it/following{/other_user}","gists_url":"https://api.github.com/users/ox-it/gists{/gist_id}","starred_url":"https://api.github.com/users/ox-it/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ox-it/subscriptions","organizations_url":"https://api.github.com/users/ox-it/orgs","repos_url":"https://api.github.com/users/ox-it/repos","events_url":"https://api.github.com/users/ox-it/events{/privacy}","received_events_url":"https://api.github.com/users/ox-it/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ox-it/talks.ox","description":"New version of Oxford Talks","fork":false,"url":"https://api.github.com/repos/ox-it/talks.ox","forks_url":"https://api.github.com/repos/ox-it/talks.ox/forks","keys_url":"https://api.github.com/repos/ox-it/talks.ox/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ox-it/talks.ox/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ox-it/talks.ox/teams","hooks_url":"https://api.github.com/repos/ox-it/talks.ox/hooks","issue_events_url":"https://api.github.com/repos/ox-it/talks.ox/issues/events{/number}","events_url":"https://api.github.com/repos/ox-it/talks.ox/events","assignees_url":"https://api.github.com/repos/ox-it/talks.ox/assignees{/user}","branches_url":"https://api.github.com/repos/ox-it/talks.ox/branches{/branch}","tags_url":"https://api.github.com/repos/ox-it/talks.ox/tags","blobs_url":"https://api.github.com/repos/ox-it/talks.ox/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ox-it/talks.ox/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ox-it/talks.ox/git/refs{/sha}","trees_url":"https://api.github.com/repos/ox-it/talks.ox/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ox-it/talks.ox/statuses/{sha}","languages_url":"https://api.github.com/repos/ox-it/talks.ox/languages","stargazers_url":"https://api.github.com/repos/ox-it/talks.ox/stargazers","contributors_url":"https://api.github.com/repos/ox-it/talks.ox/contributors","subscribers_url":"https://api.github.com/repos/ox-it/talks.ox/subscribers","subscription_url":"https://api.github.com/repos/ox-it/talks.ox/subscription","commits_url":"https://api.github.com/repos/ox-it/talks.ox/commits{/sha}","git_commits_url":"https://api.github.com/repos/ox-it/talks.ox/git/commits{/sha}","comments_url":"https://api.github.com/repos/ox-it/talks.ox/comments{/number}","issue_comment_url":"https://api.github.com/repos/ox-it/talks.ox/issues/comments{/number}","contents_url":"https://api.github.com/repos/ox-it/talks.ox/contents/{+path}","compare_url":"https://api.github.com/repos/ox-it/talks.ox/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ox-it/talks.ox/merges","archive_url":"https://api.github.com/repos/ox-it/talks.ox/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ox-it/talks.ox/downloads","issues_url":"https://api.github.com/repos/ox-it/talks.ox/issues{/number}","pulls_url":"https://api.github.com/repos/ox-it/talks.ox/pulls{/number}","milestones_url":"https://api.github.com/repos/ox-it/talks.ox/milestones{/number}","notifications_url":"https://api.github.com/repos/ox-it/talks.ox/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ox-it/talks.ox/labels{/name}","releases_url":"https://api.github.com/repos/ox-it/talks.ox/releases{/id}","created_at":"2014-05-14T14:51:26Z","updated_at":"2015-04-17T16:06:50Z","pushed_at":"2015-08-03T15:35:33Z","git_url":"git://github.com/ox-it/talks.ox.git","ssh_url":"git@github.com:ox-it/talks.ox.git","clone_url":"https://github.com/ox-it/talks.ox.git","svn_url":"https://github.com/ox-it/talks.ox","homepage":null,"size":5508,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":60,"forks":0,"open_issues":60,"watchers":0,"default_branch":"master"}},"base":{"label":"ox-it:new-fe","ref":"new-fe","sha":"b96b2ffb05835f0c89cbcdcb6868e3b7b76b3365","user":{"login":"ox-it","id":351950,"avatar_url":"https://avatars.githubusercontent.com/u/351950?v=3","gravatar_id":"","url":"https://api.github.com/users/ox-it","html_url":"https://github.com/ox-it","followers_url":"https://api.github.com/users/ox-it/followers","following_url":"https://api.github.com/users/ox-it/following{/other_user}","gists_url":"https://api.github.com/users/ox-it/gists{/gist_id}","starred_url":"https://api.github.com/users/ox-it/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ox-it/subscriptions","organizations_url":"https://api.github.com/users/ox-it/orgs","repos_url":"https://api.github.com/users/ox-it/repos","events_url":"https://api.github.com/users/ox-it/events{/privacy}","received_events_url":"https://api.github.com/users/ox-it/received_events","type":"Organization","site_admin":false},"repo":{"id":19783550,"name":"talks.ox","full_name":"ox-it/talks.ox","owner":{"login":"ox-it","id":351950,"avatar_url":"https://avatars.githubusercontent.com/u/351950?v=3","gravatar_id":"","url":"https://api.github.com/users/ox-it","html_url":"https://github.com/ox-it","followers_url":"https://api.github.com/users/ox-it/followers","following_url":"https://api.github.com/users/ox-it/following{/other_user}","gists_url":"https://api.github.com/users/ox-it/gists{/gist_id}","starred_url":"https://api.github.com/users/ox-it/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ox-it/subscriptions","organizations_url":"https://api.github.com/users/ox-it/orgs","repos_url":"https://api.github.com/users/ox-it/repos","events_url":"https://api.github.com/users/ox-it/events{/privacy}","received_events_url":"https://api.github.com/users/ox-it/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ox-it/talks.ox","description":"New version of Oxford Talks","fork":false,"url":"https://api.github.com/repos/ox-it/talks.ox","forks_url":"https://api.github.com/repos/ox-it/talks.ox/forks","keys_url":"https://api.github.com/repos/ox-it/talks.ox/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ox-it/talks.ox/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ox-it/talks.ox/teams","hooks_url":"https://api.github.com/repos/ox-it/talks.ox/hooks","issue_events_url":"https://api.github.com/repos/ox-it/talks.ox/issues/events{/number}","events_url":"https://api.github.com/repos/ox-it/talks.ox/events","assignees_url":"https://api.github.com/repos/ox-it/talks.ox/assignees{/user}","branches_url":"https://api.github.com/repos/ox-it/talks.ox/branches{/branch}","tags_url":"https://api.github.com/repos/ox-it/talks.ox/tags","blobs_url":"https://api.github.com/repos/ox-it/talks.ox/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ox-it/talks.ox/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ox-it/talks.ox/git/refs{/sha}","trees_url":"https://api.github.com/repos/ox-it/talks.ox/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ox-it/talks.ox/statuses/{sha}","languages_url":"https://api.github.com/repos/ox-it/talks.ox/languages","stargazers_url":"https://api.github.com/repos/ox-it/talks.ox/stargazers","contributors_url":"https://api.github.com/repos/ox-it/talks.ox/contributors","subscribers_url":"https://api.github.com/repos/ox-it/talks.ox/subscribers","subscription_url":"https://api.github.com/repos/ox-it/talks.ox/subscription","commits_url":"https://api.github.com/repos/ox-it/talks.ox/commits{/sha}","git_commits_url":"https://api.github.com/repos/ox-it/talks.ox/git/commits{/sha}","comments_url":"https://api.github.com/repos/ox-it/talks.ox/comments{/number}","issue_comment_url":"https://api.github.com/repos/ox-it/talks.ox/issues/comments{/number}","contents_url":"https://api.github.com/repos/ox-it/talks.ox/contents/{+path}","compare_url":"https://api.github.com/repos/ox-it/talks.ox/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ox-it/talks.ox/merges","archive_url":"https://api.github.com/repos/ox-it/talks.ox/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ox-it/talks.ox/downloads","issues_url":"https://api.github.com/repos/ox-it/talks.ox/issues{/number}","pulls_url":"https://api.github.com/repos/ox-it/talks.ox/pulls{/number}","milestones_url":"https://api.github.com/repos/ox-it/talks.ox/milestones{/number}","notifications_url":"https://api.github.com/repos/ox-it/talks.ox/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ox-it/talks.ox/labels{/name}","releases_url":"https://api.github.com/repos/ox-it/talks.ox/releases{/id}","created_at":"2014-05-14T14:51:26Z","updated_at":"2015-04-17T16:06:50Z","pushed_at":"2015-08-03T15:35:33Z","git_url":"git://github.com/ox-it/talks.ox.git","ssh_url":"git@github.com:ox-it/talks.ox.git","clone_url":"https://github.com/ox-it/talks.ox.git","svn_url":"https://github.com/ox-it/talks.ox","homepage":null,"size":5508,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":60,"forks":0,"open_issues":60,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ox-it/talks.ox/pulls/349"},"html":{"href":"https://github.com/ox-it/talks.ox/pull/349"},"issue":{"href":"https://api.github.com/repos/ox-it/talks.ox/issues/349"},"comments":{"href":"https://api.github.com/repos/ox-it/talks.ox/issues/349/comments"},"review_comments":{"href":"https://api.github.com/repos/ox-it/talks.ox/pulls/349/comments"},"review_comment":{"href":"https://api.github.com/repos/ox-it/talks.ox/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ox-it/talks.ox/pulls/349/commits"},"statuses":{"href":"https://api.github.com/repos/ox-it/talks.ox/statuses/5dd28f23505578db2569c86cefa54ec7ce9833b8"}}}}