{"action":"created","comment":{"url":"https://api.github.com/repos/biocore/qiita/pulls/comments/56072071","id":56072071,"diff_hunk":"@@ -40,20 +59,81 @@ def new_prep_template_get_req(study_id):\n     data_types = sorted(Study.all_data_types())\n \n     # Get all the ENA terms for the investigation type\n-    ontology = Ontology(convert_to_id('ENA', 'ontology'))\n-    ena_terms = sorted(ontology.terms)\n-    # make \"Other\" last on the list\n-    ena_terms.remove('Other')\n-    ena_terms.append('Other')\n+    ontology_info = _get_ENA_ontology()\n \n-    ontology_info = {'ENA': ena_terms,\n-                     'User': sorted(ontology.user_defined_terms)}\n     return {'status': 'success',\n             'prep_files': prep_files,\n             'data_types': data_types,\n             'ontology': ontology_info}\n \n \n+def prep_template_ajax_get_req(prep_id):\n+    \"\"\"Returns the prep tempalte information needed for the AJAX handler\n+\n+    Parameters\n+    ----------\n+    prep_id : int\n+        The prep template id\n+\n+    Returns\n+    -------\n+    dict of {str: object}\n+        A dictionary with the following keys:\n+        - status: str, whether if the request is successful or not\n+        - message: str, if the request is unsuccessful, a human readable error\n+        - name: str, the name of the prep template\n+        - files: list of str, the files available to update the prep template\n+        - download_prep: int, the filepath_id of the prep file\n+        - download_qiime, int, the filepath_id of the qiime mapping file\n+        - num_samples: int, the number of samples present in the template\n+        - num_columns: int, the number of columns present in the template\n+        - investigation_type: str, the investigation type of the template\n+        - ontology: str, dict of {str, list of str} conataining the information\n+        of the ENA ontology\n+        - artifact_attached: bool, whethe the template has an artifact attached\n+        - study_id: int, the study id of the template\n+    \"\"\"\n+    # Currently there is no name attribute, but it will be soon\n+    name = \"Prep information %d\" % prep_id\n+    pt = PrepTemplate(prep_id)\n+    artifact_attached = pt.artifact is not None\n+    study_id = pt.study_id\n+    files = [f for _, f in get_files_from_uploads_folders(study_id)\n+             if f.endswith(('txt', 'tsv'))]\n+\n+    # The call to list is needed because keys is an iterator\n+    num_samples = len(list(pt.keys()))\n+    num_columns = len(pt.categories())\n+    investigation_type = pt.investigation_type\n+\n+    # Retrieve the information to download the prep template and QIIME\n+    # mapping file. See issue https://github.com/biocore/qiita/issues/1675\n+    download_prep = []\n+    download_qiime = []\n+    for fp_id, fp in pt.get_filepaths():\n+        if 'qiime' in basename(fp):\n+            download_qiime.append(fp_id)\n+        else:\n+            download_prep.append(fp_id)\n+    download_prep = download_prep[0]\n+    download_qiime = download_qiime[0]\n+\n+    ontology = _get_ENA_ontology()\n+\n+    return {'status': 'success',","path":"qiita_pet/handlers/api_proxy/prep_template.py","position":105,"original_position":105,"commit_id":"4d153e4db941a3031db02d6045bc63e48dafcf3e","original_commit_id":"4d153e4db941a3031db02d6045bc63e48dafcf3e","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":"If the status is hard-coded as a return value, then do we need this at all?","created_at":"2016-03-14T20:42:10Z","updated_at":"2016-03-14T20:42:10Z","html_url":"https://github.com/biocore/qiita/pull/1683#discussion_r56072071","pull_request_url":"https://api.github.com/repos/biocore/qiita/pulls/1683","_links":{"self":{"href":"https://api.github.com/repos/biocore/qiita/pulls/comments/56072071"},"html":{"href":"https://github.com/biocore/qiita/pull/1683#discussion_r56072071"},"pull_request":{"href":"https://api.github.com/repos/biocore/qiita/pulls/1683"}}},"pull_request":{"url":"https://api.github.com/repos/biocore/qiita/pulls/1683","id":62584927,"html_url":"https://github.com/biocore/qiita/pull/1683","diff_url":"https://github.com/biocore/qiita/pull/1683.diff","patch_url":"https://github.com/biocore/qiita/pull/1683.patch","issue_url":"https://api.github.com/repos/biocore/qiita/issues/1683","number":1683,"state":"open","locked":false,"title":"Refactoring the refactor (III): prep summary","user":{"login":"josenavas","id":2501478,"avatar_url":"https://avatars.githubusercontent.com/u/2501478?v=3","gravatar_id":"","url":"https://api.github.com/users/josenavas","html_url":"https://github.com/josenavas","followers_url":"https://api.github.com/users/josenavas/followers","following_url":"https://api.github.com/users/josenavas/following{/other_user}","gists_url":"https://api.github.com/users/josenavas/gists{/gist_id}","starred_url":"https://api.github.com/users/josenavas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/josenavas/subscriptions","organizations_url":"https://api.github.com/users/josenavas/orgs","repos_url":"https://api.github.com/users/josenavas/repos","events_url":"https://api.github.com/users/josenavas/events{/privacy}","received_events_url":"https://api.github.com/users/josenavas/received_events","type":"User","site_admin":false},"body":"Depends on #1680, so review/merge that one first\r\n\r\nThis PR refactors the prep information summary page and integrates the artifact creation in this page. ","created_at":"2016-03-11T18:44:29Z","updated_at":"2016-03-14T20:42:10Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0eeaf9c308ecb2da92cb8354042564951fb16e9e","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/biocore/qiita/pulls/1683/commits","review_comments_url":"https://api.github.com/repos/biocore/qiita/pulls/1683/comments","review_comment_url":"https://api.github.com/repos/biocore/qiita/pulls/comments{/number}","comments_url":"https://api.github.com/repos/biocore/qiita/issues/1683/comments","statuses_url":"https://api.github.com/repos/biocore/qiita/statuses/4d153e4db941a3031db02d6045bc63e48dafcf3e","head":{"label":"josenavas:artifact-study-pages-prep-artifact-integration","ref":"artifact-study-pages-prep-artifact-integration","sha":"4d153e4db941a3031db02d6045bc63e48dafcf3e","user":{"login":"josenavas","id":2501478,"avatar_url":"https://avatars.githubusercontent.com/u/2501478?v=3","gravatar_id":"","url":"https://api.github.com/users/josenavas","html_url":"https://github.com/josenavas","followers_url":"https://api.github.com/users/josenavas/followers","following_url":"https://api.github.com/users/josenavas/following{/other_user}","gists_url":"https://api.github.com/users/josenavas/gists{/gist_id}","starred_url":"https://api.github.com/users/josenavas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/josenavas/subscriptions","organizations_url":"https://api.github.com/users/josenavas/orgs","repos_url":"https://api.github.com/users/josenavas/repos","events_url":"https://api.github.com/users/josenavas/events{/privacy}","received_events_url":"https://api.github.com/users/josenavas/received_events","type":"User","site_admin":false},"repo":{"id":13527677,"name":"QiiTa","full_name":"josenavas/QiiTa","owner":{"login":"josenavas","id":2501478,"avatar_url":"https://avatars.githubusercontent.com/u/2501478?v=3","gravatar_id":"","url":"https://api.github.com/users/josenavas","html_url":"https://github.com/josenavas","followers_url":"https://api.github.com/users/josenavas/followers","following_url":"https://api.github.com/users/josenavas/following{/other_user}","gists_url":"https://api.github.com/users/josenavas/gists{/gist_id}","starred_url":"https://api.github.com/users/josenavas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/josenavas/subscriptions","organizations_url":"https://api.github.com/users/josenavas/orgs","repos_url":"https://api.github.com/users/josenavas/repos","events_url":"https://api.github.com/users/josenavas/events{/privacy}","received_events_url":"https://api.github.com/users/josenavas/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/josenavas/QiiTa","description":"QiiTa databasing effort","fork":true,"url":"https://api.github.com/repos/josenavas/QiiTa","forks_url":"https://api.github.com/repos/josenavas/QiiTa/forks","keys_url":"https://api.github.com/repos/josenavas/QiiTa/keys{/key_id}","collaborators_url":"https://api.github.com/repos/josenavas/QiiTa/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/josenavas/QiiTa/teams","hooks_url":"https://api.github.com/repos/josenavas/QiiTa/hooks","issue_events_url":"https://api.github.com/repos/josenavas/QiiTa/issues/events{/number}","events_url":"https://api.github.com/repos/josenavas/QiiTa/events","assignees_url":"https://api.github.com/repos/josenavas/QiiTa/assignees{/user}","branches_url":"https://api.github.com/repos/josenavas/QiiTa/branches{/branch}","tags_url":"https://api.github.com/repos/josenavas/QiiTa/tags","blobs_url":"https://api.github.com/repos/josenavas/QiiTa/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/josenavas/QiiTa/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/josenavas/QiiTa/git/refs{/sha}","trees_url":"https://api.github.com/repos/josenavas/QiiTa/git/trees{/sha}","statuses_url":"https://api.github.com/repos/josenavas/QiiTa/statuses/{sha}","languages_url":"https://api.github.com/repos/josenavas/QiiTa/languages","stargazers_url":"https://api.github.com/repos/josenavas/QiiTa/stargazers","contributors_url":"https://api.github.com/repos/josenavas/QiiTa/contributors","subscribers_url":"https://api.github.com/repos/josenavas/QiiTa/subscribers","subscription_url":"https://api.github.com/repos/josenavas/QiiTa/subscription","commits_url":"https://api.github.com/repos/josenavas/QiiTa/commits{/sha}","git_commits_url":"https://api.github.com/repos/josenavas/QiiTa/git/commits{/sha}","comments_url":"https://api.github.com/repos/josenavas/QiiTa/comments{/number}","issue_comment_url":"https://api.github.com/repos/josenavas/QiiTa/issues/comments{/number}","contents_url":"https://api.github.com/repos/josenavas/QiiTa/contents/{+path}","compare_url":"https://api.github.com/repos/josenavas/QiiTa/compare/{base}...{head}","merges_url":"https://api.github.com/repos/josenavas/QiiTa/merges","archive_url":"https://api.github.com/repos/josenavas/QiiTa/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/josenavas/QiiTa/downloads","issues_url":"https://api.github.com/repos/josenavas/QiiTa/issues{/number}","pulls_url":"https://api.github.com/repos/josenavas/QiiTa/pulls{/number}","milestones_url":"https://api.github.com/repos/josenavas/QiiTa/milestones{/number}","notifications_url":"https://api.github.com/repos/josenavas/QiiTa/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/josenavas/QiiTa/labels{/name}","releases_url":"https://api.github.com/repos/josenavas/QiiTa/releases{/id}","deployments_url":"https://api.github.com/repos/josenavas/QiiTa/deployments","created_at":"2013-10-12T19:29:32Z","updated_at":"2015-05-05T22:50:05Z","pushed_at":"2016-03-14T16:39:06Z","git_url":"git://github.com/josenavas/QiiTa.git","ssh_url":"git@github.com:josenavas/QiiTa.git","clone_url":"https://github.com/josenavas/QiiTa.git","svn_url":"https://github.com/josenavas/QiiTa","homepage":null,"size":129608,"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":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"biocore:artifact-study-pages","ref":"artifact-study-pages","sha":"ef83464889d2e9b303b4128b5eb4ed6178f83fb9","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}","deployments_url":"https://api.github.com/repos/biocore/qiita/deployments","created_at":"2013-09-26T18:50:43Z","updated_at":"2016-01-31T22:47:34Z","pushed_at":"2016-03-14T16:48:51Z","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":130263,"stargazers_count":25,"watchers_count":25,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":28,"mirror_url":null,"open_issues_count":325,"forks":28,"open_issues":325,"watchers":25,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/biocore/qiita/pulls/1683"},"html":{"href":"https://github.com/biocore/qiita/pull/1683"},"issue":{"href":"https://api.github.com/repos/biocore/qiita/issues/1683"},"comments":{"href":"https://api.github.com/repos/biocore/qiita/issues/1683/comments"},"review_comments":{"href":"https://api.github.com/repos/biocore/qiita/pulls/1683/comments"},"review_comment":{"href":"https://api.github.com/repos/biocore/qiita/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/biocore/qiita/pulls/1683/commits"},"statuses":{"href":"https://api.github.com/repos/biocore/qiita/statuses/4d153e4db941a3031db02d6045bc63e48dafcf3e"}}}}