-
Notifications
You must be signed in to change notification settings - Fork 80
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
Delete prep template #850
Conversation
I think you need to pull from upstream/master, but I could be wrong. On (Feb-12-15|11:31), Antonio Gonzalez wrote:
|
…_prep_template
Done. |
PrepTemplate.delete(prep_template_id) | ||
msg = ("Prep template %d has been deleted" % prep_template_id) | ||
msg_level = "success" | ||
tab = 'study_information_tab' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably better to redirect in either case to the raw_data_tab? So from the user point of view the only change on the screen is that the prep template has been remove, rather than move to the RawData tab after the prep template is removed (he probably wants to add another prep template just after removing one).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
msg = ("Couldn't remove prep template: %s" % str(e)) | ||
msg_level = "danger" | ||
|
||
callback((msg, msg_level, 'raw_data_tab', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This now is broken. If the removal worked successfully, the PrepTemplate with id prep_template_id
no longer works. You just need to move the query to PrepTemplate(prep_template_id).raw_data
before the try statement
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -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): |
There was a problem hiding this comment.
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))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found another issue. Part of it is out of the scope of this PR but I think is easy enough to fix here too. The removal of a raw data/prep template can be done independently of the study status. However, if a study is private/public raw data and prep templates can be removed. I don't think this should be allowed, at least if the study is public. If the study is private, however, I can see some discussion. But I would advocate that the user is adding metadata (prep template) so it should be checked... |
I see you point but I do not think that's possible because to be able
to make it public you need processed object and if you have one, you
can not remove the preprocessed data, and if you ..., get it?
Either way, I can add that test, but depending where we do the
validation (qiita_db or qiita_pet), we will need to check the study
status. I will like to have it in qiita_db but that will require to
pass/create an study object within those objects. What do you think?
|
You can have a processed object from one raw data, but not from the other one. And you still will be able to delete that other one... Is just the idea that our "public" data should not be mutable in an easy way (or at least not by a normal user, just by an admin...). I don't have strong feelings on where to put the check. Although it is a pretty light check on qiita_db that will not require interaction with the server, as the the study_status property is already used extensively in the study_description page. you can potentially propagate that value through the calls to the uimodules, so less DB interactions are needed. (Also if you feel like it, adding a double check on qiita_db never hurts!) |
msg_level = "danger" | ||
prep_id = prep_template_id | ||
|
||
callback((msg, msg_level, 'raw_data_tab', tab_id, None)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should pass prep_id
instead of None
here.
@josenavas and I discussed his comment offline and realized that we have a bigger issue and it's described here: #855 |
Given that we have created another issue to keep track of my concern, I would say that this PR is good to go. So if another developer can review this and agrees with the code, feel free to merge! |
is done | ||
""" | ||
prep_template_id = int(self.get_argument('prep_template_id')) | ||
tab_id = PrepTemplate(prep_template_id).raw_data |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like tab_id
could easily be replaced by prep_id
. Plus I don't understand why the name of this variable is tab..
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is not the prep_id
. Is the raw_data_id
. Also the name is tab because the callback function expect a message, the message level, the name of tab group to show, the id in that group (tab_id) and the id of the sub_tab in case that the previous ID points to another tab group.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, ok. In any case using a single variable should work (I think).
On (Feb-13-15|14:17), josenavas wrote:
@@ -613,6 +613,34 @@ def delete_raw_data(self, study, user, callback):
callback((msg, msg_level, tab, tab_id, None))
- def delete_prep_template(self, study, user, callback):
"""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'))
tab_id = PrepTemplate(prep_template_id).raw_data
is not the
prep_id
. Is theraw_data_id
. Also the name is tab because the callback function expect a message, the message level, the name of tab group to show, the id in that group (tab_id) and the id of the sub_tab in case that the previous ID points to another tab group.
Reply to this email directly or view it on GitHub:
https://github.com/biocore/qiita/pull/850/files#r24701698
Just one comment, looks good otherwise. |
OK, the latest push should address your two comments. Note that I completely deactivated the collapse on the prep templates cause (1) I spent a lot of time trying to figure out how to prevent it when you cancel the erase and (2) cause this is really confusing to users and the reason I deactivated by default in the first place. |
Thanks working in that, but now I can't click the delete button. On the On (Feb-14-15| 6:38), Antonio Gonzalez wrote:
|
The tests passed but not sure why the PR wasn't updated. |
Tested it and it looks good! |
#842 should be merged first.