Skip to content

Commit 9b6db64

Browse files
committed
Merge pull request #686 from antgonza/prep-sample-template-download-permissions
fixing small issue in the prep templates download permissions
2 parents 13c7fbd + 1a52772 commit 9b6db64

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

qiita_db/meta_util.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
from .study import Study
2929
from .data import RawData, PreprocessedData, ProcessedData
3030
from .analysis import Analysis
31+
from .metadata_template import PrepTemplate, SampleTemplate
3132

3233

3334
def _get_data_fpids(constructor, object_id):
@@ -84,6 +85,18 @@ def get_accessible_filepath_ids(user_id):
8485
for data_id in data_ids:
8586
filepath_ids.update(_get_data_fpids(constructor, data_id))
8687

88+
# adding prep and sample templates
89+
prep_fp_ids = []
90+
for rdid in study.raw_data():
91+
for pt_id in RawData(rdid).prep_templates:
92+
for _id, _ in PrepTemplate(pt_id).get_filepaths():
93+
prep_fp_ids.append(_id)
94+
95+
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)
99+
87100
# Next, analyses
88101
# Same as before, ther eare public, private, and shared
89102
analysis_ids = Analysis.get_by_status('public') + user.private_analyses + \

qiita_db/test/test_meta_util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def test_get_accessible_filepath_ids(self):
2828

2929
# shared has access to all study files and analysis files
3030
obs = get_accessible_filepath_ids('shared@foo.bar')
31-
self.assertEqual(obs, set([1, 2, 3, 4, 5, 6, 7, 11, 14, 15]))
31+
self.assertEqual(obs, set([1, 2, 3, 4, 5, 6, 7, 11, 14, 15, 16]))
3232

3333
# Now shared should not have access to the study files
3434
self._unshare_studies()

0 commit comments

Comments
 (0)