Skip to content

Commit 62ccfcc

Browse files
committed
adding GUI
1 parent 00b317e commit 62ccfcc

File tree

2 files changed

+65
-0
lines changed

2 files changed

+65
-0
lines changed

qiita_pet/handlers/study_handlers/description_handlers.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,32 @@ def display_template(self, study, user, msg, msg_level, full_access,
640640
sub_tab=sub_tab,
641641
prep_tab=prep_tab)
642642

643+
def delete_study(self, study, user, callback):
644+
"""Delete study
645+
646+
Parameters
647+
----------
648+
study : Study
649+
The current study object
650+
user : User
651+
The current user object
652+
callback : function
653+
The callback function to call with the results once the processing
654+
is done and it fails
655+
"""
656+
study_id = study.id
657+
study_title = study.title
658+
659+
try:
660+
Study.delete(study_id)
661+
self.redirect('/study/list/')
662+
except Exception as e:
663+
msg = "Couldn't remove study ID: %d <i>%s</i> : %s" % (
664+
study_id, study_title, str(e))
665+
msg_level = "danger"
666+
667+
callback((msg, msg_level, 'study_information_tab', None, None))
668+
643669
def delete_sample_template(self, study, user, callback):
644670
"""Delete sample template
645671
@@ -808,6 +834,7 @@ def post(self, study_id):
808834
request_approval=self.request_approval,
809835
make_sandbox=self.make_sandbox,
810836
update_investigation_type=self.update_investigation_type,
837+
delete_study=self.delete_study,
811838
delete_sample_template=self.delete_sample_template,
812839
delete_raw_data=self.delete_raw_data,
813840
delete_prep_template=self.delete_prep_template,

qiita_pet/templates/study_description.html

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,26 @@
184184
form.submit();
185185
}
186186

187+
function delete_study() {
188+
if ($("#study-alias").val() != "{{study_alias}}") {
189+
alert("The added name doesn't match the study alias");
190+
return false;
191+
}
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();
205+
}
206+
187207
function delete_sample_template() {
188208
sample_template_id = {{study.sample_template}};
189209
if (confirm('Are you sure you want to delete sample template ID: ' + sample_template_id + '?')) {
@@ -548,6 +568,7 @@ <h2><i>{{study_alias}}</i></h2>
548568
<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>
549569
{% end %}
550570
<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>
551572
</td>
552573
</tr>
553574
</table>
@@ -580,4 +601,21 @@ <h2><i>{{study_alias}}</i></h2>
580601
{% end %}
581602
</div>
582603

604+
605+
<div class="modal fade delete-study" tabindex="-1" role="dialog" id="delete-study">
606+
<div class="modal-dialog modal-sm">
607+
<div class="modal-content">
608+
<div class="modal-header">
609+
<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.
611+
</div>
612+
<div class="modal-body">
613+
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>
616+
</div>
617+
</div>
618+
</div>
619+
</div>
620+
583621
{% end %}

0 commit comments

Comments
 (0)