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

Conversation

antgonza
Copy link
Member

#842 should be merged first.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.26%) to 78.33% when pulling 1b36d1e on antgonza:delete_prep_template into 1ca033a on biocore:master.

@ElDeveloper
Copy link
Contributor

I think you need to pull from upstream/master, but I could be wrong.

On (Feb-12-15|11:31), Antonio Gonzalez wrote:

#842 should be merged first.
You can view, comment on, or merge this pull request online at:

#850

-- Commit Summary --

-- File Changes --

M qiita_db/data.py (98)
M qiita_db/test/test_data.py (37)
M qiita_pet/handlers/study_handlers/description_handlers.py (63)
M qiita_pet/templates/study_description.html (38)
M qiita_pet/templates/study_description_templates/prep_template_panel.html (5)
M qiita_pet/templates/study_description_templates/raw_data_tab.html (5)

-- Patch Links --

https://github.com/biocore/qiita/pull/850.patch
https://github.com/biocore/qiita/pull/850.diff


Reply to this email directly or view it on GitHub:
#850

@antgonza
Copy link
Member Author

Done.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.16%) to 78.33% when pulling 8608e82 on antgonza:delete_prep_template into 3ff89b8 on biocore:master.

PrepTemplate.delete(prep_template_id)
msg = ("Prep template %d has been deleted" % prep_template_id)
msg_level = "success"
tab = 'study_information_tab'
Copy link
Contributor

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).

Copy link
Member Author

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',
Copy link
Contributor

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

Copy link
Member Author

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):
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.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.11%) to 78.39% when pulling 36f0628 on antgonza:delete_prep_template into 3ff89b8 on biocore:master.

@josenavas
Copy link
Contributor

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...

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.14%) to 78.36% when pulling 1742f8f on antgonza:delete_prep_template into 3ff89b8 on biocore:master.

@antgonza
Copy link
Member Author

antgonza commented Feb 13, 2015 via email

@josenavas
Copy link
Contributor

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))
Copy link
Contributor

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.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.17%) to 78.33% when pulling 8574c3a on antgonza:delete_prep_template into 3ff89b8 on biocore:master.

@antgonza
Copy link
Member Author

@josenavas and I discussed his comment offline and realized that we have a bigger issue and it's described here: #855

@josenavas
Copy link
Contributor

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
Copy link
Contributor

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...

Copy link
Contributor

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.

Copy link
Contributor

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 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.


Reply to this email directly or view it on GitHub:
https://github.com/biocore/qiita/pull/850/files#r24701698

@ElDeveloper
Copy link
Contributor

Just one comment, looks good otherwise.

@antgonza
Copy link
Member Author

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.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.16%) to 78.34% when pulling 5bf3134 on antgonza:delete_prep_template into 3ff89b8 on biocore:master.

@ElDeveloper
Copy link
Contributor

Thanks working in that, but now I can't click the delete button. On the
bright side, the accordion no longer collapses.

On (Feb-14-15| 6:38), Antonio Gonzalez wrote:

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.


Reply to this email directly or view it on GitHub:
#850 (comment)

@antgonza
Copy link
Member Author

The tests passed but not sure why the PR wasn't updated.

ElDeveloper added a commit that referenced this pull request Feb 15, 2015
@ElDeveloper ElDeveloper merged commit d398414 into qiita-spots:master Feb 15, 2015
@ElDeveloper
Copy link
Contributor

Tested it and it looks good!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants