Skip to content

Delete prep template #850

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 11 commits into from
Feb 15, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
30 changes: 29 additions & 1 deletion qiita_pet/handlers/study_handlers/description_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,33 @@ def delete_raw_data(self, study, user, callback):

callback((msg, msg_level, tab, tab_id, None))

def delete_prep_template(self, study, user, callback):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is still broken... (sorry) the actual code should be this one:

prep_template_id = int(self.get_argument('prep_template_id'))
tab_id = PrepTemplate(prep_template_id).raw_data

try:
    PrepTemplate.delete(prep_template_id)
    msg = ("Prep template %d has been deleted" % prep_template_id)
    msg_level = "success"
    prep_id = None
except Exception as e:
    msg = ("Couldn't remove prep template: %s" % str(e))
    msg_level = "danger"
    prep_id = prep_template_id

callback((msg, msg_level, 'raw_data_tab', tab_id, prep_template_id))

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"""Delete the selected prep template

Parameters
----------
study : Study
The current study object
user : User
The current user object
callback : function
The callback function to call with the results once the processing
is done
"""
prep_template_id = int(self.get_argument('prep_template_id'))
prep_id = PrepTemplate(prep_template_id).raw_data

try:
PrepTemplate.delete(prep_template_id)
msg = ("Prep template %d has been deleted" % prep_template_id)
msg_level = "success"
prep_id = None
except Exception as e:
msg = ("Couldn't remove prep template: %s" % str(e))
msg_level = "danger"

callback((msg, msg_level, 'raw_data_tab', prep_id, None))

@authenticated
def get(self, study_id):
study, user = self._get_sudy_and_check_access(study_id)
Expand Down Expand Up @@ -640,7 +667,8 @@ def post(self, study_id):
request_approval=self.request_approval,
make_sandbox=self.make_sandbox,
update_investigation_type=self.update_investigation_type,
delete_raw_data=self.delete_raw_data)
delete_raw_data=self.delete_raw_data,
delete_prep_template=self.delete_prep_template)

# Get the action that we need to perform
action = self.get_argument("action", None)
Expand Down
21 changes: 20 additions & 1 deletion qiita_pet/templates/study_description.html
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@
}
}


function delete_raw_data(raw_data_filetype, raw_data_id) {
if (confirm('Are you sure you want to delete raw data: ' + raw_data_filetype + ' (ID: ' + raw_data_id + ')?')) {
var form = $("<form>")
Expand All @@ -171,6 +170,26 @@
}
}

function delete_prep_template(data_type, prep_template_id) {
if (confirm('Are you sure you want to delete prep template: ' + data_type + ' (ID: ' + prep_template_id + ')?')) {
var form = $("<form>")
.attr("action", window.location.href)
.attr("method", "post")
.append($("<input>")
.attr("type", "hidden")
.attr("name", "prep_template_id")
.attr("value", prep_template_id))
.append($("<input>")
.attr("type", "hidden")
.attr("name", "action")
.attr("value", "delete_prep_template"));
$("body").append(form);
form.submit();
} else {
return false;
}
}

function make_public() {
if (confirm("Are you sure you want to make this study public?")) {
var form = $("<form>")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ <h4 class="modal-title" id="myModalLabel">Choose preprocessing parameters</h4>
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#prep-accordion" href="#collapse{{prep_id}}">{{data_type}} (ID: {{prep_id}})</a>
<a data-parent="#prep-accordion" href="#collapse{{prep_id}}" style="pointer-events: none; cursor: default;">{{data_type}} (ID: {{prep_id}})</a>
<button class="close" title="Remove this prep template" type="button" onclick="delete_prep_template('{{data_type}}', {{prep_id}})">&nbsp; ×</button>
</h4>
</div>
<div id="collapse{{prep_id}}" class="panel-collapse collapse in">
Expand Down