Skip to content

Commit ac20386

Browse files
committed
addressing @ElDeveloper comments
1 parent e958282 commit ac20386

File tree

2 files changed

+32
-19
lines changed

2 files changed

+32
-19
lines changed

qiita_db/study.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,13 +360,13 @@ def delete(cls, id_):
360360
Raises
361361
------
362362
QiitaDBError
363-
If the sample_(_id) table exists == a sample template exists
363+
If the sample_(id_) table exists means a sample template exists
364364
"""
365365
cls._check_subclass()
366366

367367
conn_handler = SQLConnectionHandler()
368368
if exists_table('sample_%d' % id_, conn_handler):
369-
raise QiitaDBError('Study "%s" can not be erased because it has a '
369+
raise QiitaDBError('Study "%s" cannot be erased because it has a '
370370
'sample template' % cls(id_).title)
371371

372372
queue = "delete_study_%d" % id_

qiita_pet/templates/study_description.html

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -184,24 +184,34 @@
184184
form.submit();
185185
}
186186

187+
function validate_delete_study_text() {
188+
if ($("#study-alias").val() == "{{study_alias}}") {
189+
$('#delete-study-button').prop('disabled', false);
190+
} else {
191+
$('#delete-study-button').prop('disabled', true);
192+
}
193+
}
194+
187195
function delete_study() {
188196
if ($("#study-alias").val() != "{{study_alias}}") {
189197
alert("The added name doesn't match the study alias");
190198
return false;
191199
}
192-
var form = $("<form>")
193-
.attr("action", window.location.href)
194-
.attr("method", "post")
195-
.append($("<input>")
196-
.attr("type", "hidden")
197-
.attr("name", "study_id")
198-
.attr("value", {{study.id}}))
199-
.append($("<input>")
200-
.attr("type", "hidden")
201-
.attr("name", "action")
202-
.attr("value", "delete_study"));
203-
$("body").append(form);
204-
form.submit();
200+
if (confirm('Are you sure you want to delete "{{study_title}}"?')) {
201+
var form = $("<form>")
202+
.attr("action", window.location.href)
203+
.attr("method", "post")
204+
.append($("<input>")
205+
.attr("type", "hidden")
206+
.attr("name", "study_id")
207+
.attr("value", {{study.id}}))
208+
.append($("<input>")
209+
.attr("type", "hidden")
210+
.attr("name", "action")
211+
.attr("value", "delete_study"));
212+
$("body").append(form);
213+
form.submit();
214+
}
205215
}
206216

207217
function delete_sample_template() {
@@ -568,7 +578,7 @@ <h2><i>{{study_alias}}</i></h2>
568578
<a class="btn btn-default glyphicon glyphicon-edit" href="/study/edit/{{study.id}}" title="Edit the study information" style="margin:5px; word-spacing: -10px;"> Edit</a>
569579
{% end %}
570580
<a href="/study/upload/{{study.id}}" class="btn btn-default glyphicon glyphicon-upload" title="Upload study files" style="margin:5px; word-spacing: -10px;"> Upload</a>
571-
<a class="btn btn-danger glyphicon glyphicon-trash" data-toggle="modal" data-target="#delete-study"></a>
581+
<a class="btn btn-danger glyphicon glyphicon-trash" style="display: inline-block;" data-toggle="modal" data-target="#delete-study"> Delete-study</a>
572582
</td>
573583
</tr>
574584
</table>
@@ -606,13 +616,16 @@ <h2><i>{{study_alias}}</i></h2>
606616
<div class="modal-dialog modal-sm">
607617
<div class="modal-content">
608618
<div class="modal-header">
619+
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
609620
<h3>Deleting:<br/></h3><h4>{{study_title}}</h4>
610-
You will only be able to delete a study that has no data associated with it.
611621
</div>
612622
<div class="modal-body">
623+
You will only be able to delete a study that has no data associated with it.
624+
</div>
625+
<div class="modal-footer">
613626
To continue you need to write the alias name of the study:
614-
<input type="text" name="study-alias" id="study-alias">
615-
<a class="btn btn-danger glyphicon glyphicon-trash" onclick="delete_study()"></a>
627+
<input type="text" name="study-alias" id="study-alias" onkeyup="validate_delete_study_text();">
628+
<button class="btn btn-danger glyphicon glyphicon-trash" onclick="delete_study();" id="delete-study-button" disabled></button>
616629
</div>
617630
</div>
618631
</div>

0 commit comments

Comments
 (0)