Skip to content

Commit a0628e5

Browse files
committed
Merge pull request #688 from antgonza/actual-fix-to-download-permissions
actual fix
2 parents 9b6db64 + b571a82 commit a0628e5

File tree

2 files changed

+31
-4
lines changed

2 files changed

+31
-4
lines changed

qiita_db/meta_util.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,12 @@ def get_accessible_filepath_ids(user_id):
9191
for pt_id in RawData(rdid).prep_templates:
9292
for _id, _ in PrepTemplate(pt_id).get_filepaths():
9393
prep_fp_ids.append(_id)
94-
9594
filepath_ids.update(prep_fp_ids)
96-
sample_fp_ids = [_id for _id, _
97-
in SampleTemplate(study_id).get_filepaths()]
98-
filepath_ids.update(sample_fp_ids)
95+
96+
if SampleTemplate.exists(study_id):
97+
sample_fp_ids = [_id for _id, _
98+
in SampleTemplate(study_id).get_filepaths()]
99+
filepath_ids.update(sample_fp_ids)
99100

100101
# Next, analyses
101102
# Same as before, ther eare public, private, and shared

qiita_db/test/test_meta_util.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
from qiita_core.util import qiita_test_checker
1212
from qiita_db.meta_util import get_accessible_filepath_ids
13+
from qiita_db.study import Study
14+
from qiita_db.user import User
1315

1416

1517
@qiita_test_checker()
@@ -40,5 +42,29 @@ def test_get_accessible_filepath_ids(self):
4042
obs = get_accessible_filepath_ids('[email protected]')
4143
self.assertEqual(obs, set())
4244

45+
# Test that it doesn't brake if the SampleTemplate hasn't been added
46+
exp = set([1, 2, 3, 4, 5, 6, 7, 11, 14, 15, 16])
47+
obs = get_accessible_filepath_ids('[email protected]')
48+
self.assertEqual(obs, exp)
49+
50+
info = {
51+
"timeseries_type_id": 1,
52+
"metadata_complete": True,
53+
"mixs_compliant": True,
54+
"number_samples_collected": 4,
55+
"number_samples_promised": 4,
56+
"portal_type_id": 3,
57+
"study_alias": "TestStudy",
58+
"study_description": "Description of a test study",
59+
"study_abstract": "No abstract right now...",
60+
"emp_person_id": 1,
61+
"principal_investigator_id": 1,
62+
"lab_person_id": 1
63+
}
64+
Study.create(User('[email protected]'), "Test study", [1], info)
65+
obs = get_accessible_filepath_ids('[email protected]')
66+
self.assertEqual(obs, exp)
67+
68+
4369
if __name__ == '__main__':
4470
main()

0 commit comments

Comments
 (0)