{"action":"created","comment":{"url":"https://api.github.com/repos/biocore/qiita/pulls/comments/47548556","id":47548556,"diff_hunk":"@@ -0,0 +1,117 @@\n+# -----------------------------------------------------------------------------\n+# Copyright (c) 2014--, The Qiita Development Team.\n+#\n+# Distributed under the terms of the BSD 3-clause License.\n+#\n+# The full license is in the file LICENSE, distributed with this software.\n+# -----------------------------------------------------------------------------\n+from __future__ import division\n+\n+# This is the only file in qiita_pet that should import from outside qiita_pet\n+# The idea is that this proxies the call and response dicts we expect from the\n+# QIITA API once we build it. This will be removed and replaced with API calls\n+# when the API is complete.\n+from qiita_core.qiita_settings import qiita_config\n+from qiita_db.study import Study\n+\n+from qiita_pet.handlers.base_handlers import BaseHandler\n+from qiita_pet.handlers.util import check_access\n+\n+html_error_message = \"<b>An error occurred %s %s</b></br>%s\"\n+\n+\n+def _approve(level):\n+    \"\"\"Check if the study can be approved based on user level and configuration\n+\n+    Parameters\n+    ----------\n+    level : str\n+        The level of the current user\n+\n+    Returns\n+    -------\n+    bool\n+        Whether the study can be approved or not\n+    \"\"\"\n+    return True if not qiita_config.require_approval else level == 'admin'\n+\n+\n+class StudyAPIProxy(BaseHandler):\n+    \"\"\"Adds API proxy functions to the handler. Can be removed once the restful\n+       API is in place.\"\"\"\n+    def study_prep_proxy(self, study_id):\n+        \"\"\"Proxies expected json from the API for existing prep templates\n+\n+        Parameters\n+        ----------\n+        study_id : int\n+            Study id to get prep template info for\n+\n+        Returns:\n+        dict of list of dict\n+            prep template information seperated by data type, in the form\n+            {data_type: [{prep 1 info dict}, ....], ...}\n+        \"\"\"\n+        # Can only pass ids over API, so need to instantiate object\n+        study = Study(study_id)\n+        check_access(self.current_user, study, raise_error=True)\n+        prep_info = {}\n+        for dtype in study.data_types:\n+            prep_info[dtype] = []\n+            for prep in study.prep_templates(dtype):\n+                start_artifact = prep.artifact\n+                info = {\n+                    'name': 'PREP %d NAME' % prep.id,\n+                    'id': prep.id,\n+                    'status': prep.status,\n+                    'start_artifact': start_artifact.artifact_type,\n+                    'start_artifact_id': start_artifact.id,\n+                    'last_artifact': 'TODO new gui'\n+                }\n+                prep_info[dtype].append(info)\n+        return prep_info\n+\n+    def study_data_types_proxy(self):\n+        \"\"\"Proxies expected json from the API for available data types\n+\n+        Returns\n+        -------\n+        list of str\n+            Data types available on the system\n+        \"\"\"\n+        data_types = Study.all_data_types()\n+        return data_types if data_types else []\n+\n+    def study_info_proxy(self, study_id):\n+        \"\"\"Proxies expected json from the API for base study info\n+\n+        Parameters\n+        ----------\n+        study_id : int\n+            Study id to get prep template info for\n+\n+        Returns:\n+        dict of list of dict\n+            prep template information seperated by data type, in the form\n+            {data_type: [{prep 1 info dict}, ....], ...}\n+        \"\"\"\n+        # Can only pass ids over API, so need to instantiate object\n+        study = Study(study_id)\n+        check_access(self.current_user, study, raise_error=True)","path":"qiita_pet/handlers/api_proxy.py","position":107,"original_position":100,"commit_id":"f251b7b50aa29e4b8ae4ced1e3d47aeb7ef4764d","original_commit_id":"e27be7667f87c9c4d3df96240ab432a20b0e63b3","user":{"login":"ElDeveloper","id":375307,"avatar_url":"https://avatars.githubusercontent.com/u/375307?v=3","gravatar_id":"","url":"https://api.github.com/users/ElDeveloper","html_url":"https://github.com/ElDeveloper","followers_url":"https://api.github.com/users/ElDeveloper/followers","following_url":"https://api.github.com/users/ElDeveloper/following{/other_user}","gists_url":"https://api.github.com/users/ElDeveloper/gists{/gist_id}","starred_url":"https://api.github.com/users/ElDeveloper/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ElDeveloper/subscriptions","organizations_url":"https://api.github.com/users/ElDeveloper/orgs","repos_url":"https://api.github.com/users/ElDeveloper/repos","events_url":"https://api.github.com/users/ElDeveloper/events{/privacy}","received_events_url":"https://api.github.com/users/ElDeveloper/received_events","type":"User","site_admin":false},"body":"Can you add this error to the `Raises` section of the docstring?","created_at":"2015-12-14T19:53:34Z","updated_at":"2015-12-14T19:53:34Z","html_url":"https://github.com/biocore/qiita/pull/1571#discussion_r47548556","pull_request_url":"https://api.github.com/repos/biocore/qiita/pulls/1571","_links":{"self":{"href":"https://api.github.com/repos/biocore/qiita/pulls/comments/47548556"},"html":{"href":"https://github.com/biocore/qiita/pull/1571#discussion_r47548556"},"pull_request":{"href":"https://api.github.com/repos/biocore/qiita/pulls/1571"}}},"pull_request":{"url":"https://api.github.com/repos/biocore/qiita/pulls/1571","id":53194250,"html_url":"https://github.com/biocore/qiita/pull/1571","diff_url":"https://github.com/biocore/qiita/pull/1571.diff","patch_url":"https://github.com/biocore/qiita/pull/1571.patch","issue_url":"https://api.github.com/repos/biocore/qiita/issues/1571","number":1571,"state":"open","locked":false,"title":"Base for new study page","user":{"login":"squirrelo","id":3079066,"avatar_url":"https://avatars.githubusercontent.com/u/3079066?v=3","gravatar_id":"","url":"https://api.github.com/users/squirrelo","html_url":"https://github.com/squirrelo","followers_url":"https://api.github.com/users/squirrelo/followers","following_url":"https://api.github.com/users/squirrelo/following{/other_user}","gists_url":"https://api.github.com/users/squirrelo/gists{/gist_id}","starred_url":"https://api.github.com/users/squirrelo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/squirrelo/subscriptions","organizations_url":"https://api.github.com/users/squirrelo/orgs","repos_url":"https://api.github.com/users/squirrelo/repos","events_url":"https://api.github.com/users/squirrelo/events{/privacy}","received_events_url":"https://api.github.com/users/squirrelo/received_events","type":"User","site_admin":false},"body":"This adds in the base HTML and index handler for the study pages, and a single example of the AJAX-call-based updates done on the page. The idea is that we load the minimal information to show the first page, and then lazy load each bit of information needed as it is called for, so we save a lot of time and database calls that would be duplicated if we just reloaded the page for every link click. It also means we no longer need to load all information for all files when the page is accessed.","created_at":"2015-12-09T23:26:23Z","updated_at":"2015-12-14T19:53:35Z","closed_at":null,"merged_at":null,"merge_commit_sha":"aeaaf4702ada7e56ba3397fed4dd66b3c8dcb002","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/biocore/qiita/pulls/1571/commits","review_comments_url":"https://api.github.com/repos/biocore/qiita/pulls/1571/comments","review_comment_url":"https://api.github.com/repos/biocore/qiita/pulls/comments{/number}","comments_url":"https://api.github.com/repos/biocore/qiita/issues/1571/comments","statuses_url":"https://api.github.com/repos/biocore/qiita/statuses/f251b7b50aa29e4b8ae4ced1e3d47aeb7ef4764d","head":{"label":"squirrelo:study-base","ref":"study-base","sha":"f251b7b50aa29e4b8ae4ced1e3d47aeb7ef4764d","user":{"login":"squirrelo","id":3079066,"avatar_url":"https://avatars.githubusercontent.com/u/3079066?v=3","gravatar_id":"","url":"https://api.github.com/users/squirrelo","html_url":"https://github.com/squirrelo","followers_url":"https://api.github.com/users/squirrelo/followers","following_url":"https://api.github.com/users/squirrelo/following{/other_user}","gists_url":"https://api.github.com/users/squirrelo/gists{/gist_id}","starred_url":"https://api.github.com/users/squirrelo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/squirrelo/subscriptions","organizations_url":"https://api.github.com/users/squirrelo/orgs","repos_url":"https://api.github.com/users/squirrelo/repos","events_url":"https://api.github.com/users/squirrelo/events{/privacy}","received_events_url":"https://api.github.com/users/squirrelo/received_events","type":"User","site_admin":false},"repo":{"id":21153084,"name":"qiita","full_name":"squirrelo/qiita","owner":{"login":"squirrelo","id":3079066,"avatar_url":"https://avatars.githubusercontent.com/u/3079066?v=3","gravatar_id":"","url":"https://api.github.com/users/squirrelo","html_url":"https://github.com/squirrelo","followers_url":"https://api.github.com/users/squirrelo/followers","following_url":"https://api.github.com/users/squirrelo/following{/other_user}","gists_url":"https://api.github.com/users/squirrelo/gists{/gist_id}","starred_url":"https://api.github.com/users/squirrelo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/squirrelo/subscriptions","organizations_url":"https://api.github.com/users/squirrelo/orgs","repos_url":"https://api.github.com/users/squirrelo/repos","events_url":"https://api.github.com/users/squirrelo/events{/privacy}","received_events_url":"https://api.github.com/users/squirrelo/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/squirrelo/qiita","description":"Qiita - A QIIME databasing effort","fork":true,"url":"https://api.github.com/repos/squirrelo/qiita","forks_url":"https://api.github.com/repos/squirrelo/qiita/forks","keys_url":"https://api.github.com/repos/squirrelo/qiita/keys{/key_id}","collaborators_url":"https://api.github.com/repos/squirrelo/qiita/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/squirrelo/qiita/teams","hooks_url":"https://api.github.com/repos/squirrelo/qiita/hooks","issue_events_url":"https://api.github.com/repos/squirrelo/qiita/issues/events{/number}","events_url":"https://api.github.com/repos/squirrelo/qiita/events","assignees_url":"https://api.github.com/repos/squirrelo/qiita/assignees{/user}","branches_url":"https://api.github.com/repos/squirrelo/qiita/branches{/branch}","tags_url":"https://api.github.com/repos/squirrelo/qiita/tags","blobs_url":"https://api.github.com/repos/squirrelo/qiita/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/squirrelo/qiita/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/squirrelo/qiita/git/refs{/sha}","trees_url":"https://api.github.com/repos/squirrelo/qiita/git/trees{/sha}","statuses_url":"https://api.github.com/repos/squirrelo/qiita/statuses/{sha}","languages_url":"https://api.github.com/repos/squirrelo/qiita/languages","stargazers_url":"https://api.github.com/repos/squirrelo/qiita/stargazers","contributors_url":"https://api.github.com/repos/squirrelo/qiita/contributors","subscribers_url":"https://api.github.com/repos/squirrelo/qiita/subscribers","subscription_url":"https://api.github.com/repos/squirrelo/qiita/subscription","commits_url":"https://api.github.com/repos/squirrelo/qiita/commits{/sha}","git_commits_url":"https://api.github.com/repos/squirrelo/qiita/git/commits{/sha}","comments_url":"https://api.github.com/repos/squirrelo/qiita/comments{/number}","issue_comment_url":"https://api.github.com/repos/squirrelo/qiita/issues/comments{/number}","contents_url":"https://api.github.com/repos/squirrelo/qiita/contents/{+path}","compare_url":"https://api.github.com/repos/squirrelo/qiita/compare/{base}...{head}","merges_url":"https://api.github.com/repos/squirrelo/qiita/merges","archive_url":"https://api.github.com/repos/squirrelo/qiita/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/squirrelo/qiita/downloads","issues_url":"https://api.github.com/repos/squirrelo/qiita/issues{/number}","pulls_url":"https://api.github.com/repos/squirrelo/qiita/pulls{/number}","milestones_url":"https://api.github.com/repos/squirrelo/qiita/milestones{/number}","notifications_url":"https://api.github.com/repos/squirrelo/qiita/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/squirrelo/qiita/labels{/name}","releases_url":"https://api.github.com/repos/squirrelo/qiita/releases{/id}","created_at":"2014-06-24T05:18:58Z","updated_at":"2015-05-06T16:22:32Z","pushed_at":"2015-12-14T19:50:15Z","git_url":"git://github.com/squirrelo/qiita.git","ssh_url":"git@github.com:squirrelo/qiita.git","clone_url":"https://github.com/squirrelo/qiita.git","svn_url":"https://github.com/squirrelo/qiita","homepage":"","size":21659,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"biocore:artifact-study-pages","ref":"artifact-study-pages","sha":"68328357cbbc3dbc0dfc137a102ecb8ee9e9cb62","user":{"login":"biocore","id":6241857,"avatar_url":"https://avatars.githubusercontent.com/u/6241857?v=3","gravatar_id":"","url":"https://api.github.com/users/biocore","html_url":"https://github.com/biocore","followers_url":"https://api.github.com/users/biocore/followers","following_url":"https://api.github.com/users/biocore/following{/other_user}","gists_url":"https://api.github.com/users/biocore/gists{/gist_id}","starred_url":"https://api.github.com/users/biocore/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/biocore/subscriptions","organizations_url":"https://api.github.com/users/biocore/orgs","repos_url":"https://api.github.com/users/biocore/repos","events_url":"https://api.github.com/users/biocore/events{/privacy}","received_events_url":"https://api.github.com/users/biocore/received_events","type":"Organization","site_admin":false},"repo":{"id":13131245,"name":"qiita","full_name":"biocore/qiita","owner":{"login":"biocore","id":6241857,"avatar_url":"https://avatars.githubusercontent.com/u/6241857?v=3","gravatar_id":"","url":"https://api.github.com/users/biocore","html_url":"https://github.com/biocore","followers_url":"https://api.github.com/users/biocore/followers","following_url":"https://api.github.com/users/biocore/following{/other_user}","gists_url":"https://api.github.com/users/biocore/gists{/gist_id}","starred_url":"https://api.github.com/users/biocore/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/biocore/subscriptions","organizations_url":"https://api.github.com/users/biocore/orgs","repos_url":"https://api.github.com/users/biocore/repos","events_url":"https://api.github.com/users/biocore/events{/privacy}","received_events_url":"https://api.github.com/users/biocore/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/biocore/qiita","description":"Qiita - A QIIME databasing effort","fork":false,"url":"https://api.github.com/repos/biocore/qiita","forks_url":"https://api.github.com/repos/biocore/qiita/forks","keys_url":"https://api.github.com/repos/biocore/qiita/keys{/key_id}","collaborators_url":"https://api.github.com/repos/biocore/qiita/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/biocore/qiita/teams","hooks_url":"https://api.github.com/repos/biocore/qiita/hooks","issue_events_url":"https://api.github.com/repos/biocore/qiita/issues/events{/number}","events_url":"https://api.github.com/repos/biocore/qiita/events","assignees_url":"https://api.github.com/repos/biocore/qiita/assignees{/user}","branches_url":"https://api.github.com/repos/biocore/qiita/branches{/branch}","tags_url":"https://api.github.com/repos/biocore/qiita/tags","blobs_url":"https://api.github.com/repos/biocore/qiita/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/biocore/qiita/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/biocore/qiita/git/refs{/sha}","trees_url":"https://api.github.com/repos/biocore/qiita/git/trees{/sha}","statuses_url":"https://api.github.com/repos/biocore/qiita/statuses/{sha}","languages_url":"https://api.github.com/repos/biocore/qiita/languages","stargazers_url":"https://api.github.com/repos/biocore/qiita/stargazers","contributors_url":"https://api.github.com/repos/biocore/qiita/contributors","subscribers_url":"https://api.github.com/repos/biocore/qiita/subscribers","subscription_url":"https://api.github.com/repos/biocore/qiita/subscription","commits_url":"https://api.github.com/repos/biocore/qiita/commits{/sha}","git_commits_url":"https://api.github.com/repos/biocore/qiita/git/commits{/sha}","comments_url":"https://api.github.com/repos/biocore/qiita/comments{/number}","issue_comment_url":"https://api.github.com/repos/biocore/qiita/issues/comments{/number}","contents_url":"https://api.github.com/repos/biocore/qiita/contents/{+path}","compare_url":"https://api.github.com/repos/biocore/qiita/compare/{base}...{head}","merges_url":"https://api.github.com/repos/biocore/qiita/merges","archive_url":"https://api.github.com/repos/biocore/qiita/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/biocore/qiita/downloads","issues_url":"https://api.github.com/repos/biocore/qiita/issues{/number}","pulls_url":"https://api.github.com/repos/biocore/qiita/pulls{/number}","milestones_url":"https://api.github.com/repos/biocore/qiita/milestones{/number}","notifications_url":"https://api.github.com/repos/biocore/qiita/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/biocore/qiita/labels{/name}","releases_url":"https://api.github.com/repos/biocore/qiita/releases{/id}","created_at":"2013-09-26T18:50:43Z","updated_at":"2015-09-20T19:09:27Z","pushed_at":"2015-12-14T19:50:16Z","git_url":"git://github.com/biocore/qiita.git","ssh_url":"git@github.com:biocore/qiita.git","clone_url":"https://github.com/biocore/qiita.git","svn_url":"https://github.com/biocore/qiita","homepage":"http://qiita.microbio.me","size":128477,"stargazers_count":24,"watchers_count":24,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":26,"mirror_url":null,"open_issues_count":320,"forks":26,"open_issues":320,"watchers":24,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/biocore/qiita/pulls/1571"},"html":{"href":"https://github.com/biocore/qiita/pull/1571"},"issue":{"href":"https://api.github.com/repos/biocore/qiita/issues/1571"},"comments":{"href":"https://api.github.com/repos/biocore/qiita/issues/1571/comments"},"review_comments":{"href":"https://api.github.com/repos/biocore/qiita/pulls/1571/comments"},"review_comment":{"href":"https://api.github.com/repos/biocore/qiita/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/biocore/qiita/pulls/1571/commits"},"statuses":{"href":"https://api.github.com/repos/biocore/qiita/statuses/f251b7b50aa29e4b8ae4ced1e3d47aeb7ef4764d"}}}}