Skip to content

Commit 2b6fb46

Browse files
Charles CowartCharles Cowart
authored andcommitted
Merge branch 'master' of https://github.com/biocore/qiita into dev
2 parents 32a12bd + 36b3ccc commit 2b6fb46

File tree

5 files changed

+35
-8
lines changed

5 files changed

+35
-8
lines changed
368 Bytes
Binary file not shown.

qiita_db/meta_util.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,16 @@ def validate_filepath_access_by_user(user, filepath_id):
110110
if arid:
111111
# [0] cause we should only have 1
112112
artifact = qdb.artifact.Artifact(arid[0])
113+
113114
if artifact.visibility == 'public':
115+
# TODO: https://github.com/biocore/qiita/issues/1724
116+
if artifact.artifact_type in ['SFF', 'FASTQ', 'FASTA',
117+
'FASTA_Sanger',
118+
'per_sample_FASTQ']:
119+
study = artifact.study
120+
has_access = study.has_access(user, no_public=True)
121+
if (not study.public_raw_download and not has_access):
122+
return False
114123
return True
115124
else:
116125
study = artifact.study

qiita_db/test/test_meta_util.py

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,18 @@ def test_validate_filepath_access_by_user(self):
6868
# Now shared has access to public study files
6969
self._set_artifact_public()
7070
for i in [1, 2, 3, 4, 5, 9, 12, 17, 18, 19, 20, 21]:
71-
self.assertTrue(qdb.meta_util.validate_filepath_access_by_user(
72-
user, i))
71+
obs = qdb.meta_util.validate_filepath_access_by_user(user, i)
72+
if i < 3:
73+
self.assertFalse(obs)
74+
else:
75+
self.assertTrue(obs)
76+
77+
# testing that if study.public_raw_download is true we get access
78+
qdb.study.Study(1).public_raw_download = True
79+
for i in [1, 2, 3]:
80+
obs = qdb.meta_util.validate_filepath_access_by_user(user, i)
81+
self.assertTrue(obs)
82+
qdb.study.Study(1).public_raw_download = False
7383

7484
# Test that it doesn't break: if the SampleTemplate hasn't been added
7585
info = {
@@ -88,15 +98,21 @@ def test_validate_filepath_access_by_user(self):
8898
study = qdb.study.Study.create(
8999
qdb.user.User('[email protected]'), "Test study", info)
90100
for i in [1, 2, 3, 4, 5, 9, 12, 17, 18, 19, 20, 21]:
91-
self.assertTrue(qdb.meta_util.validate_filepath_access_by_user(
92-
user, i))
101+
obs = qdb.meta_util.validate_filepath_access_by_user(user, i)
102+
if i < 3:
103+
self.assertFalse(obs)
104+
else:
105+
self.assertTrue(obs)
93106

94107
# test in case there is a prep template that failed
95108
self.conn_handler.execute(
96109
"INSERT INTO qiita.prep_template (data_type_id) VALUES (2)")
97110
for i in [1, 2, 3, 4, 5, 9, 12, 17, 18, 19, 20, 21]:
98-
self.assertTrue(qdb.meta_util.validate_filepath_access_by_user(
99-
user, i))
111+
obs = qdb.meta_util.validate_filepath_access_by_user(user, i)
112+
if i < 3:
113+
self.assertFalse(obs)
114+
else:
115+
self.assertTrue(obs)
100116

101117
# admin should have access to everything
102118
admin = qdb.user.User('[email protected]')

qiita_pet/handlers/artifact_handlers/base_handlers.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,9 @@ def artifact_summary_get_request(user, artifact_id):
185185
'per_sample_FASTQ']:
186186
# If the artifact is one of the "raw" types, only the owner of the
187187
# study and users that has been shared with can see the files
188-
if not artifact.study.has_access(user, no_public=True):
188+
study = artifact.study
189+
has_access = study.has_access(user, no_public=True)
190+
if (not study.public_raw_download and not has_access):
189191
files = []
190192

191193
proc_params = artifact.processing_parameters

travis_ebi_setup.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
set -e
22
echo "** Testing EBI **"
3-
openssl aes-256-cbc -K $encrypted_bcdc06e5ae76_key -iv $encrypted_bcdc06e5ae76_iv -in qiita_core/support_files/config_test.cfg.enc -out qiita_core/support_files/config_test.cfg -d
3+
openssl aes-256-cbc -K $encrypted_079e536628f1_key -iv $encrypted_079e536628f1_iv -in qiita_core/support_files/config_test.cfg.enc -out qiita_core/support_files/config_test.cfg -d

0 commit comments

Comments
 (0)