Skip to content

Commit a0ed1d5

Browse files
committed
fixing sql and test
1 parent 9fc1283 commit a0ed1d5

File tree

4 files changed

+13
-10
lines changed

4 files changed

+13
-10
lines changed

qiita_db/data.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -364,15 +364,18 @@ def delete(cls, raw_data_id, study_id):
364364
"doesn't exist" % (raw_data_id, study_id))
365365

366366
# check if there are any prep templates for this study
367-
prep_template_count = conn_handler.execute_fetchone(
367+
prep_template_exists = conn_handler.execute_fetchone(
368368
"""
369369
SELECT EXISTS(
370370
SELECT * FROM qiita.prep_template AS pt
371-
JOIN qiita.study_raw_data AS srd on
372-
pt.raw_data_id=srd.raw_data_id
373-
WHERE srd.raw_data_id={0} AND srd.study_id={1})
371+
LEFT JOIN qiita.common_prep_info AS cpi ON
372+
(pt.prep_template_id=cpi.prep_template_id)
373+
LEFT JOIN qiita.required_sample_info AS rsi ON
374+
(cpi.sample_id=rsi.sample_id)
375+
WHERE raw_data_id = {0} and study_id = {1}
376+
)
374377
""".format(raw_data_id, study_id))[0]
375-
if prep_template_count:
378+
if prep_template_exists:
376379
raise QiitaDBError(
377380
"Raw data %d has prep template(s) associated so it can't be "
378381
"erased." % raw_data_id)

qiita_db/test/test_data.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,8 @@ def test_delete(self):
284284
RawData.delete(3, 1)
285285

286286
# the raw data is linked to a study that has not prep templates
287-
Study(2).add_raw_data([RawData(3)])
288-
RawData.delete(3, 2)
287+
Study(2).add_raw_data([RawData(1)])
288+
RawData.delete(1, 2)
289289

290290
# delete raw data
291291
self.assertTrue(RawData.exists(2))

qiita_pet/templates/study_description.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,8 @@
153153
}
154154

155155

156-
function delete_raw_data(raw_data_id) {
157-
if (confirm("Are you sure you want to delete raw data " + raw_data_id + "?")) {
156+
function delete_raw_data(raw_data_filetype, raw_data_id) {
157+
if (confirm('Are you sure you want to delete raw data: ' + raw_data_filetype + ' (ID: ' + raw_data_id + ')?')) {
158158
var form = $("<form>")
159159
.attr("action", window.location.href)
160160
.attr("method", "post")

qiita_pet/templates/study_description_templates/raw_data_tab.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
{% for rd_id, rd_filetype, _ in available_raw_data %}
88
<li><a href="#raw_data_info_{{rd_id}}" role="tab" data-toggle="tab">
99
{{rd_filetype}} (ID: {{rd_id}})
10-
<button class="close" title="Remove this raw data" type="button" onclick="delete_raw_data({{rd_id}})">&nbsp; ×</button>
10+
<button class="close" title="Remove this raw data" type="button" onclick="delete_raw_data('{{rd_filetype}}', {{rd_id}})">&nbsp; ×</button>
1111
</a></li>
1212
{% end %}
1313
</ul>

0 commit comments

Comments
 (0)