Skip to content

Release candidate #2298

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 120 commits into from
Sep 19, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
120 commits
Select commit Hold shift + click to select a range
6080742
Merge pull request #2249 from biocore/release-candidate
josenavas Aug 23, 2017
52e98a5
replace printable for try/except utf-8
antgonza Aug 28, 2017
e367b54
add sleeps for tests
antgonza Aug 28, 2017
5f7177e
moving wait_for_prep_information_job
antgonza Aug 28, 2017
01da18f
just leaving the changes on this pr
antgonza Aug 28, 2017
2ae9511
Fixing tests
josenavas Aug 28, 2017
2026d0c
Reverting changes
josenavas Aug 28, 2017
f098fcf
dist: precise
antgonza Aug 28, 2017
97a8397
Merge branch 'printable-to-utf8' of https://github.com/antgonza/qiita…
antgonza Aug 28, 2017
e195e07
addressing @josenavas comments
antgonza Aug 29, 2017
ef4f566
Merge pull request #2255 from antgonza/printable-to-utf8
josenavas Aug 29, 2017
7d5da5c
fix-2212
josenavas Aug 29, 2017
21f0287
Adding branch description to Contributing (#2256)
josenavas Aug 29, 2017
2e102b4
Merge branch 'dev' of https://github.com/biocore/qiita into dev
josenavas Aug 31, 2017
de5c89f
upgrading software
antgonza Aug 31, 2017
6248208
mv r_client to qiita
antgonza Aug 31, 2017
eb19870
from redis import Redis
antgonza Aug 31, 2017
120e9ac
Merge pull request #2261 from antgonza/upgrading-software
josenavas Aug 31, 2017
58e2dab
Merge branch 'remove-moi' of https://github.com/biocore/qiita into r_…
antgonza Aug 31, 2017
8b4ce80
Merge pull request #2262 from antgonza/r_client-to-qiita
josenavas Aug 31, 2017
fa7cf3d
rm moi and ipython
antgonza Aug 31, 2017
a47c13b
Move qiita_db/private.py -> qiita_ware/private_plugin.py
josenavas Aug 31, 2017
c8c1b59
_system_call as system_call
antgonza Aug 31, 2017
c46c05f
flake8
antgonza Aug 31, 2017
f7e9b1e
rm create_raw_data
antgonza Aug 31, 2017
c16b177
Transferring VAMPS submission to internal job
josenavas Aug 31, 2017
4de94cd
rm other unnecessary files
antgonza Aug 31, 2017
f50dc35
addressing @josenavas comment
antgonza Aug 31, 2017
d4f8d8c
Merge pull request #2263 from antgonza/rm-moi-ipython
josenavas Aug 31, 2017
925a3a5
Merge branch 'remove-moi' of https://github.com/biocore/qiita into rm…
antgonza Aug 31, 2017
58cd5ae
Merge branch 'remove-moi' of https://github.com/biocore/qiita into tr…
josenavas Aug 31, 2017
0be1275
Merge pull request #2264 from antgonza/rm-create_raw_data
josenavas Aug 31, 2017
263f956
Solving merge conflicts
josenavas Aug 31, 2017
efa1924
Merge branch 'transfer-submit-to-vamps' into transfer-copy-raw-data
josenavas Aug 31, 2017
4f43236
Fixing merge conflicts
josenavas Aug 31, 2017
a528e04
Adding tests to private plugin
josenavas Aug 31, 2017
242df8e
rm wrapper.py
antgonza Aug 31, 2017
0bf7307
Removing import
josenavas Aug 31, 2017
6ee9022
Fixing import
josenavas Aug 31, 2017
c13e8bd
Merge branch 'transfer-submit-to-vamps' into transfer-copy-raw-data
josenavas Aug 31, 2017
c3bc77c
Modifying GUI to use the plugin
josenavas Aug 31, 2017
fbf5402
moving qiita pet in .travis.yml
antgonza Aug 31, 2017
71c0b41
Transfer submit to vamps (#2265)
josenavas Aug 31, 2017
b6f43c0
Merge branch 'remove-moi' of https://github.com/biocore/qiita into rm…
antgonza Aug 31, 2017
8051cbb
some other .travis.yml fixes
antgonza Aug 31, 2017
10d8cfd
Fixing import
josenavas Aug 31, 2017
df5f5c8
addressing @josenavas comment
antgonza Aug 31, 2017
5230bae
Merge pull request #2266 from antgonza/rm-wrapper.py
josenavas Aug 31, 2017
044e562
Merge branch 'remove-moi' of https://github.com/biocore/qiita into tr…
josenavas Aug 31, 2017
f2a12c6
Adding success test
josenavas Aug 31, 2017
a9e302a
adding some methods
antgonza Aug 31, 2017
dde3296
flake8
antgonza Aug 31, 2017
779a5d1
Transfer copy raw data (#2267)
josenavas Aug 31, 2017
2113fa4
fix conflicts
antgonza Aug 31, 2017
e03997a
change imports
antgonza Sep 1, 2017
48abc1e
adding delete_artifact and create_sample_template
antgonza Sep 1, 2017
2d8dffa
fixing errors and gui
antgonza Sep 1, 2017
df64ef5
fix delete error
antgonza Sep 2, 2017
dc7f78c
Merge pull request #2268 from antgonza/mv-some-methods
josenavas Sep 5, 2017
9a8d271
Merge pull request #2257 from josenavas/fix-2212
adswafford Sep 6, 2017
6673792
ENH: Make jobs list modal
ElDeveloper Sep 6, 2017
c227463
erge branch 'master' of https://github.com/biocore/qiita
antgonza Sep 7, 2017
22d52f0
Transfer update delete templates (#2274)
josenavas Sep 8, 2017
fb60c20
Merge branch 'remove-moi' of git://github.com/biocore/qiita into jobs…
ElDeveloper Sep 8, 2017
0440cb7
BUG: Fix job updates
ElDeveloper Sep 8, 2017
8178bab
Merge branch 'dev' of https://github.com/biocore/qiita
antgonza Sep 9, 2017
fb65ff1
Fixing the redis DB (#2277)
josenavas Sep 9, 2017
61e66a8
Merge branch 'remove-moi' of https://github.com/biocore/qiita into re…
antgonza Sep 10, 2017
caaf730
redbiom install
antgonza Sep 10, 2017
7b906b9
redbiom to install_requires
antgonza Sep 10, 2017
ecfbaf7
Merge branch 'remove-moi' of https://github.com/biocore/qiita into mo…
antgonza Sep 10, 2017
0a9182f
mv moi-ws to qiita_websocket
antgonza Sep 11, 2017
4ed9285
Merge pull request #2279 from antgonza/moi.send
josenavas Sep 11, 2017
45e0175
Merge pull request #2260 from biocore/remove-moi
josenavas Sep 11, 2017
6525487
Merge branch 'dev' of https://github.com/biocore/qiita into redbiom-i…
antgonza Sep 11, 2017
5e99089
init commit
antgonza Sep 11, 2017
84d1ebd
addressing @wasade comment
antgonza Sep 11, 2017
21549c1
rm webdis.log
antgonza Sep 11, 2017
8ab4066
cleaning code for initial review
antgonza Sep 13, 2017
d3590f6
install latest redbiom
antgonza Sep 13, 2017
ab397c1
fix test
antgonza Sep 13, 2017
42dd9a9
Merge pull request #2278 from antgonza/redbiom-install
josenavas Sep 13, 2017
eef49b1
Merge branch 'dev' of https://github.com/biocore/qiita into initial-r…
antgonza Sep 13, 2017
c808c63
ENH: Change phrasing of upload text (#2281)
ElDeveloper Sep 13, 2017
e482bce
addressing @wasade comments and adding other tests
antgonza Sep 13, 2017
25ee54f
flake8
antgonza Sep 13, 2017
079f4eb
addressing @josenavas comments
antgonza Sep 14, 2017
9e1c1b5
Merge pull request #2282 from antgonza/initial-redbiom-code
josenavas Sep 14, 2017
e4e8ffd
fix #2258
antgonza Sep 14, 2017
49015c2
fix #2258
antgonza Sep 14, 2017
955d5cd
fix #858 (#2286)
antgonza Sep 15, 2017
d8c4a72
addressing @ElDeveloper and @josenavas comments
antgonza Sep 15, 2017
b482b4e
@ElDeveloper :|
antgonza Sep 15, 2017
a9aa1c4
Merge pull request #2287 from antgonza/fix-2258
josenavas Sep 15, 2017
d4cc989
redbiom now adds per sample studies to analysis
antgonza Sep 15, 2017
525102e
Merge branch 'jobs-list-as-modal' of https://github.com/ElDeveloper/q…
antgonza Sep 15, 2017
7906727
jobs-list-as-modal
antgonza Sep 15, 2017
de75346
addresssing @josenavas comments
antgonza Sep 15, 2017
b8e3da4
rm () from update_processing_job_data
antgonza Sep 15, 2017
46b174e
add prints to review errors
antgonza Sep 16, 2017
38e5cd7
rm prints
antgonza Sep 16, 2017
91f0051
Merge pull request #2289 from antgonza/jobs-list-as-modal
josenavas Sep 18, 2017
ae3dc0c
Merge pull request #2288 from antgonza/redbiom-per-sample
josenavas Sep 18, 2017
c9045ff
Fix 2190 (#2292)
josenavas Sep 18, 2017
15b849f
add is_from_analysis to artifact_handlers (#2293)
antgonza Sep 18, 2017
81bd7b3
WIP: rm sudo from travis
antgonza Sep 18, 2017
191199c
adding sed for config file
antgonza Sep 18, 2017
53579aa
fix sed
antgonza Sep 18, 2017
d12ed87
rm &
antgonza Sep 18, 2017
ea5d647
cat redis.conf
antgonza Sep 18, 2017
4c40d83
using local redis.conf
antgonza Sep 18, 2017
fad8935
# protected-mode yes
antgonza Sep 18, 2017
91bdbbc
# supervised no
antgonza Sep 18, 2017
e0d83bc
redis-server --port 7777 &
antgonza Sep 18, 2017
1b7e38c
Fix 1293 (#2291)
antgonza Sep 18, 2017
6adf8b1
rm redis.conf
antgonza Sep 18, 2017
20226ed
fix awaiting_approval list bug
antgonza Sep 19, 2017
d5ecf8a
Merge pull request #2295 from antgonza/rm-sudo
josenavas Sep 19, 2017
33054b2
Merge pull request #2296 from antgonza/awaiting_approval-list
josenavas Sep 19, 2017
064d35a
Fix #2276 (#2294)
josenavas Sep 19, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix 1293 (#2291)
* fix #1293

* flake8

* fix errors

* addressing @ElDeveloper comments
  • Loading branch information
antgonza authored and ElDeveloper committed Sep 18, 2017
commit 1b7e38cb985a839f1e274a9fbf96684537fab578
22 changes: 22 additions & 0 deletions qiita_db/study.py
Original file line number Diff line number Diff line change
Expand Up @@ -998,6 +998,28 @@ def prep_templates(self, data_type=None):
return [qdb.metadata_template.prep_template.PrepTemplate(ptid)
for ptid in qdb.sql_connection.TRN.execute_fetchflatten()]

def analyses(self):
"""Get all analyses where samples from this study have been used

Returns
-------
list of qiita_db.analysis.Analysis
"""
with qdb.sql_connection.TRN:
if self.sample_template is not None:
sids = self.sample_template.keys()
if sids:
sql = """SELECT DISTINCT analysis_id
FROM qiita.analysis_sample
WHERE sample_id IN %s
ORDER BY analysis_id"""
qdb.sql_connection.TRN.add(
sql, [tuple(self.sample_template.keys())])

return [qdb.analysis.Analysis(_id) for _id in
qdb.sql_connection.TRN.execute_fetchflatten()]
return []

def has_access(self, user, no_public=False):
"""Returns whether the given user has access to the study

Expand Down
5 changes: 5 additions & 0 deletions qiita_db/support_files/patches/python_patches/58.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ def correct_redis_data(key, cmd, values_dict, user):
st_cmd = Command.create(qiita_plugin, "update_sample_template",
"Updates the sample template", parameters)

# Create the delete study command
parameters = {'study': ['integer', None]}
Command.create(qiita_plugin, "delete_study",
"Deletes a full study", parameters)

# Create the delete sample template command
parameters = {'study': ['integer', None]}
Command.create(qiita_plugin, "delete_sample_template",
Expand Down
14 changes: 14 additions & 0 deletions qiita_db/test/test_study.py
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,20 @@ def test_retrieve_prep_templates_none(self):
self.assertEqual(new.prep_templates(), [])
qdb.study.Study.delete(new.id)

def test_analyses(self):
new = qdb.study.Study.create(
qdb.user.User('test@foo.bar'),
'NOT Identification of the Microbiomes for Cannabis Soils 13',
self.info)

self.assertEqual(qdb.study.Study(1).analyses(), [
qdb.analysis.Analysis(1), qdb.analysis.Analysis(2),
qdb.analysis.Analysis(3)])

self.assertEqual(qdb.study.Study(2).analyses(), [])

qdb.study.Study.delete(new.id)

def test_environmental_packages(self):
obs = self.study.environmental_packages
exp = ['soil', 'plant-associated']
Expand Down
58 changes: 44 additions & 14 deletions qiita_pet/handlers/api_proxy/studies.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,24 @@
# -----------------------------------------------------------------------------
from __future__ import division
from collections import defaultdict
from json import dumps, loads

from future.utils import viewitems

from qiita_core.exceptions import IncompetentQiitaDeveloperError
from qiita_core.util import execute_as_transaction
from qiita_core.qiita_settings import r_client
from qiita_db.user import User
from qiita_db.study import Study
from qiita_db.metadata_template.prep_template import PrepTemplate
from qiita_db.processing_job import ProcessingJob
from qiita_db.software import Software, Parameters
from qiita_db.util import (supported_filepath_types,
get_files_from_uploads_folders)
from qiita_pet.handlers.api_proxy.util import check_access
from qiita_core.exceptions import IncompetentQiitaDeveloperError


STUDY_KEY_FORMAT = 'study_%s'


def data_types_get_req():
Expand All @@ -35,8 +43,7 @@ def data_types_get_req():
"""
return {'status': 'success',
'message': '',
'data_types': Study.all_data_types()
}
'data_types': Study.all_data_types()}


def study_get_req(study_id, user_id):
Expand Down Expand Up @@ -110,12 +117,35 @@ def study_get_req(study_id, user_id):
study_info['show_raw_download_button'] = any([
True for pt in study.prep_templates() if pt.artifact is not None])

# getting study processing status from redis
processing = False
study_info['level'] = ''
study_info['message'] = ''
job_info = r_client.get(STUDY_KEY_FORMAT % study_id)
if job_info:
job_info = defaultdict(lambda: '', loads(job_info))
job_id = job_info['job_id']
job = ProcessingJob(job_id)
job_status = job.status
processing = job_status not in ('success', 'error')
if processing:
study_info['level'] = 'info'
study_info['message'] = 'This study is currently being processed'
elif job_status == 'error':
study_info['level'] = 'danger'
study_info['message'] = job.log.msg.replace('\n', '</br>')
else:
study_info['level'] = job_info['alert_type']
study_info['message'] = job_info['alert_msg'].replace(
'\n', '</br>')

return {'status': 'success',
'message': '',
'study_info': study_info,
'editable': study.can_edit(User(user_id))}


@execute_as_transaction
def study_delete_req(study_id, user_id):
"""Delete a given study

Expand All @@ -137,17 +167,17 @@ def study_delete_req(study_id, user_id):
if access_error:
return access_error

status = 'success'
try:
Study.delete(int(study_id))
msg = ''
except Exception as e:
status = 'error'
msg = 'Unable to delete study: %s' % str(e)
return {
'status': status,
'message': msg
}
qiita_plugin = Software.from_name_and_version('Qiita', 'alpha')
cmd = qiita_plugin.get_command('delete_study')
params = Parameters.load(cmd, values_dict={'study': study_id})
job = ProcessingJob.create(User(user_id), params)
# Store the job id attaching it to the sample template id
r_client.set(STUDY_KEY_FORMAT % study_id,
dumps({'job_id': job.id}))

job.submit()

return {'status': 'success', 'message': ''}


def study_prep_get_req(study_id, user_id):
Expand Down
39 changes: 4 additions & 35 deletions qiita_pet/handlers/api_proxy/tests/test_studies.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ def test_study_get_req(self):
exp = {
'status': 'success',
'study_info': {
'mixs_compliant': True, 'metadata_complete': True,
'reprocess': False, 'owner': 'test@foo.bar',
'mixs_compliant': True, 'metadata_complete': True, 'level': '',
'reprocess': False, 'owner': 'test@foo.bar', 'message': '',
'emp_person_id': 2, 'number_samples_promised': 27,
'funding': None, 'show_biom_download_button': True,
'publication_pid': ['123456', '7891011'], 'vamps_id': None,
Expand Down Expand Up @@ -341,37 +341,6 @@ def test_study_prep_get_req_no_access(self):
'message': 'User does not have access to study'}
self.assertEqual(obs, exp)

def test_study_delete_req(self):
info = {
"timeseries_type_id": 1,
"metadata_complete": True,
"mixs_compliant": True,
"number_samples_collected": 25,
"number_samples_promised": 28,
"study_alias": "FCM",
"study_description": "DESC",
"study_abstract": "ABS",
"emp_person_id": qdb.study.StudyPerson(2),
"principal_investigator_id": qdb.study.StudyPerson(3),
"lab_person_id": qdb.study.StudyPerson(1)
}

new_study = qdb.study.Study.create(
qdb.user.User('test@foo.bar'), "Some New Study to delete", info)

study_delete_req(new_study.id, 'test@foo.bar')

with self.assertRaises(qdb.exceptions.QiitaDBUnknownIDError):
qdb.study.Study(new_study.id)

def test_study_delete_req_error(self):
obs = study_delete_req(1, 'test@foo.bar')
exp = {'status': 'error',
'message': 'Unable to delete study: Study "Identification of '
'the Microbiomes for Cannabis Soils" cannot be '
'erased because it has a sample template'}
self.assertEqual(obs, exp)

def test_study_delete_req_no_access(self):
obs = study_delete_req(1, 'demo@microbio.me')
exp = {'status': 'error',
Expand Down Expand Up @@ -525,7 +494,7 @@ def test_study_get_tags_request(self):
self.assertEqual(obs, exp)

# check error
obs = study_get_tags_request('shared@foo.bar', 2)
obs = study_get_tags_request('shared@foo.bar', 2000)
exp = {'message': 'Study does not exist', 'status': 'error'}
self.assertEqual(obs, exp)

Expand Down Expand Up @@ -560,7 +529,7 @@ def test_study_tags_patch_request(self):
self.assertEqual(obs, exp)

obs = study_tags_patch_request(
'shared@foo.bar', 2, 'replace', '/tags', ['testA', 'testB'])
'shared@foo.bar', 2000, 'replace', '/tags', ['testA', 'testB'])
exp = {'message': 'Study does not exist', 'status': 'error'}
self.assertEqual(obs, exp)

Expand Down
2 changes: 1 addition & 1 deletion qiita_pet/handlers/study_handlers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def get(self, study_id):
if study_info['status'] != 'success':
raise HTTPError(404, study_info['message'])

if message != '':
if message != '' and level != '':
study_info['level'] = level
study_info['message'] = message

Expand Down
12 changes: 0 additions & 12 deletions qiita_pet/handlers/study_handlers/tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
# The full license is in the file LICENSE, distributed with this software.
# -----------------------------------------------------------------------------
from unittest import main
from json import loads

from qiita_pet.test.tornado_test_base import TestHandlerBase
from qiita_db.handlers.tests.oauthbase import OauthTestingBase
Expand All @@ -27,17 +26,6 @@ class StudyBaseInfoAJAX(TestHandlerBase):
pass


class StudyDeleteAjaxTests(TestHandlerBase):
def test_delete_study(self):
response = self.post('/study/delete/', {'study_id': 1})
self.assertEqual(response.code, 200)
exp = {'status': 'error',
'message': 'Unable to delete study: Study "Identification of '
'the Microbiomes for Cannabis Soils" cannot be '
'erased because it has a sample template'}
self.assertEqual(loads(response.body), exp)


class DataTypesMenuAJAXTests(TestHandlerBase):
def test_get(self):
response = self.get('/study/description/data_type_menu/',
Expand Down
46 changes: 23 additions & 23 deletions qiita_pet/templates/study_base.html
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,7 @@
else if(confirm("Are you sure you want to delete {% raw study_title_msg %}?")) {
$.post('{% raw qiita_config.portal_dir %}/study/delete/', { study_id: {{study_info['study_id']}} })
.done(function ( data ) {
if(data.status == "error") {
bootstrapAlert(data.message.replace("\n", "<br/>"), "danger");
$("#delete-study").modal('hide');
} else {
window.location.replace('{% raw qiita_config.portal_dir %}/study/list/');
}
location.reload();
});
}
}
Expand Down Expand Up @@ -211,6 +206,9 @@
$("#sample-summary-btn").hide();
$("#add-new-preparation-btn").hide();
{% end %}
{% if study_info['message'] != '' %}
bootstrapAlert("{{study_info['message']}}", "{{study_info['level']}}");
{% end %}
});
</script>
<style>
Expand All @@ -223,24 +221,26 @@
{% end %}
{% block content %}
<div class="row">
<div class="col-md-3">
<button class="btn btn-default btn-block" onclick="populate_main_div('{% raw qiita_config.portal_dir %}/study/description/baseinfo/', { study_id: {{study_info['study_id']}} })"><span class="glyphicon glyphicon-info-sign"></span> Study Information</button>
<button class="btn btn-default btn-block" onclick="populate_main_div('{% raw qiita_config.portal_dir %}/study/description/sample_template/', { study_id: {{study_info['study_id']}} })"><span class="glyphicon glyphicon-info-sign"></span> Sample Information</button>
<button class="btn btn-default btn-block" onclick="populate_main_div('{% raw qiita_config.portal_dir %}/study/description/sample_summary/', { study_id: {{study_info['study_id']}} })" id="sample-summary-btn"><span class="glyphicon glyphicon-th-list"></span> Sample Summary</button>
{% if editable %}
<a class="btn btn-default btn-block" href="{% raw qiita_config.portal_dir %}/study/upload/{{study_info['study_id']}}"><span class="glyphicon glyphicon-upload"></span> Upload Files</a>
<button class="btn btn-default btn-block" onclick="populate_main_div('{% raw qiita_config.portal_dir %}/study/new_prep_template/', { study_id: {{study_info['study_id']}} })" id="add-new-preparation-btn"><span class="glyphicon glyphicon-plus-sign"></span> Add New Preparation</button>
{% end %}
{% if study_info['show_biom_download_button'] %}
<a class="btn btn-default btn-block" href="{% raw qiita_config.portal_dir %}/download_study_bioms/{{study_info['study_id']}}"><span class="glyphicon glyphicon-download-alt"></span> All QIIME maps and BIOMs</a>
{% end %}
{% if study_info['has_access_to_raw_data'] and study_info['show_raw_download_button'] %}
<a class="btn btn-default btn-block" href="{% raw qiita_config.portal_dir %}/download_raw_data/{{study_info['study_id']}}"><span class="glyphicon glyphicon-download-alt"></span> All raw data</a>
{% end %}
<div style="text-align: center;"><small><a href="{% raw qiita_config.portal_dir %}/static/doc/html/faq.html#how-to-solve-unzip-errors">Issues opening the downloaded zip?</a></small></div>
{% if study_info['level'] != 'info' %}
<div class="col-md-3">
<button class="btn btn-default btn-block" onclick="populate_main_div('{% raw qiita_config.portal_dir %}/study/description/baseinfo/', { study_id: {{study_info['study_id']}} })"><span class="glyphicon glyphicon-info-sign"></span> Study Information</button>
<button class="btn btn-default btn-block" onclick="populate_main_div('{% raw qiita_config.portal_dir %}/study/description/sample_template/', { study_id: {{study_info['study_id']}} })"><span class="glyphicon glyphicon-info-sign"></span> Sample Information</button>
<button class="btn btn-default btn-block" onclick="populate_main_div('{% raw qiita_config.portal_dir %}/study/description/sample_summary/', { study_id: {{study_info['study_id']}} })" id="sample-summary-btn"><span class="glyphicon glyphicon-th-list"></span> Sample Summary</button>
{% if editable %}
<a class="btn btn-default btn-block" href="{% raw qiita_config.portal_dir %}/study/upload/{{study_info['study_id']}}"><span class="glyphicon glyphicon-upload"></span> Upload Files</a>
<button class="btn btn-default btn-block" onclick="populate_main_div('{% raw qiita_config.portal_dir %}/study/new_prep_template/', { study_id: {{study_info['study_id']}} })" id="add-new-preparation-btn"><span class="glyphicon glyphicon-plus-sign"></span> Add New Preparation</button>
{% end %}
{% if study_info['show_biom_download_button'] %}
<a class="btn btn-default btn-block" href="{% raw qiita_config.portal_dir %}/download_study_bioms/{{study_info['study_id']}}"><span class="glyphicon glyphicon-download-alt"></span> All QIIME maps and BIOMs</a>
{% end %}
{% if study_info['has_access_to_raw_data'] and study_info['show_raw_download_button'] %}
<a class="btn btn-default btn-block" href="{% raw qiita_config.portal_dir %}/download_raw_data/{{study_info['study_id']}}"><span class="glyphicon glyphicon-download-alt"></span> All raw data</a>
{% end %}
<div style="text-align: center;"><small><a href="{% raw qiita_config.portal_dir %}/static/doc/html/faq.html#how-to-solve-unzip-errors">Issues opening the downloaded zip?</a></small></div>

<div id="data-types-menu"></div>
</div>
<div id="data-types-menu"></div>
</div>
{% end %}

<div class="col-md-9">
<!-- Study ID and study alias always on top -->
Expand Down
35 changes: 35 additions & 0 deletions qiita_ware/private_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,40 @@ def delete_sample_or_column(job):
job._set_status('success')


def delete_study(job):
"""Deletes a full study

Parameters
----------
job : qiita_db.processing_job.ProcessingJob
The processing job performing the task
"""
with qdb.sql_connection.TRN:
study_id = job.parameters.values['study']
study = qdb.study.Study(study_id)

for a in study.analyses():
artifacts = sorted(
a.artifacts, key=lambda a: a.id, reverse=True)
for artifact in artifacts:
qdb.artifact.Artifact.delete(artifact.id)
qdb.analysis.Analysis.delete(a.id)

artifacts = sorted(
study.artifacts(), key=lambda a: a.id, reverse=True)
for a in artifacts:
qdb.artifact.Artifact.delete(a.id)

for pt in study.prep_templates():
qdb.metadata_template.prep_template.PrepTemplate.delete(pt.id)

qdb.metadata_template.sample_template.SampleTemplate.delete(study_id)

qdb.study.Study.delete(study_id)

job._set_status('success')


def complete_job(job):
"""Deletes a sample or a column from the metadata

Expand Down Expand Up @@ -310,6 +344,7 @@ def complete_job(job):
'delete_sample_template': delete_sample_template,
'update_prep_template': update_prep_template,
'delete_sample_or_column': delete_sample_or_column,
'delete_study': delete_study,
'complete_job': complete_job}


Expand Down
Loading