Skip to content

delete-root-analysis-artifact #2244

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 2 commits into from
Aug 18, 2017
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
11 changes: 6 additions & 5 deletions qiita_db/artifact.py
Original file line number Diff line number Diff line change
Expand Up @@ -573,11 +573,12 @@ def delete(cls, artifact_id):
WHERE artifact_id = %s"""
qdb.sql_connection.TRN.add(sql, [artifact_id])

# If the artifact doesn't have parents, we move the files to the
# uploads folder. We also need to nullify the column in the prep
# template table
if not instance.parents:
qdb.util.move_filepaths_to_upload_folder(study.id, filepaths)
# If the artifact doesn't have parents and study is not None (is an
# analysis), we move the files to the uploads folder. We also need
# to nullify the column in the prep template table
if not instance.parents and study is not None:
qdb.util.move_filepaths_to_upload_folder(
study.id, filepaths)

sql = """UPDATE qiita.prep_template
SET artifact_id = NULL
Expand Down
3 changes: 3 additions & 0 deletions qiita_db/test/test_artifact.py
Original file line number Diff line number Diff line change
Expand Up @@ -721,6 +721,9 @@ def test_create_root_analysis(self):
self.assertIsNone(obs.study)
self.assertEqual(obs.analysis, qdb.analysis.Analysis(1))

# testing that it can be deleted
qdb.artifact.Artifact.delete(obs.id)

def test_create_processed(self):
exp_params = qdb.software.Parameters.from_default_params(
qdb.software.DefaultParameters(1), {'input_data': 1})
Expand Down