Skip to content

fix #3070 #3075

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 5 commits into from
Feb 25, 2021
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
7 changes: 6 additions & 1 deletion qiita_pet/handlers/api_proxy/artifact.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from qiita_db.software import Command, Parameters, Software
from qiita_db.processing_job import ProcessingJob
from qiita_db.exceptions import QiitaDBError
from qiita_db.logger import LogEntry

PREP_TEMPLATE_KEY_FORMAT = 'prep_template_%s'

Expand Down Expand Up @@ -323,7 +324,8 @@ def artifact_status_put_req(artifact_id, user_id, visibility):
'message': 'Unknown visibility value: %s' % visibility}

pd = Artifact(int(artifact_id))
access_error = check_access(pd.study.id, user_id)
sid = pd.study.id
access_error = check_access(sid, user_id)
if access_error:
return access_error
user = User(str(user_id))
Expand All @@ -343,5 +345,8 @@ def artifact_status_put_req(artifact_id, user_id, visibility):
else:
pd.visibility = visibility

LogEntry.create('Warning', '%s changed artifact %s (study %d) to %s' % (
user_id, artifact_id, sid, visibility))

return {'status': status,
'message': msg}
5 changes: 5 additions & 0 deletions qiita_pet/handlers/api_proxy/tests/test_artifact.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
artifact_get_req, artifact_status_put_req, artifact_graph_get_req,
artifact_types_get_req, artifact_post_req, artifact_get_prep_req,
artifact_get_info)
from qiita_db.logger import LogEntry


class TestArtifactAPIReadOnly(TestCase):
Expand Down Expand Up @@ -311,6 +312,10 @@ def test_artifact_status_put_req_private(self):
exp = {'status': 'success',
'message': 'Artifact visibility changed to private'}
self.assertEqual(obs, exp)
# testing that the log message is generated
self.assertEqual(
LogEntry.newest_records(1)[0].msg,
'admin@foo.bar changed artifact 1 (study 1) to private')

def test_artifact_status_put_req_private_bad_permissions(self):
obs = artifact_status_put_req(1, 'test@foo.bar', 'private')
Expand Down