Skip to content

fix #2258 #2287

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 4 commits into from
Sep 15, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
fix #2258
  • Loading branch information
antgonza committed Sep 14, 2017
commit e4e8ffd7a5bb988ae9f6d8e962d41233727817c3
3 changes: 1 addition & 2 deletions qiita_pet/handlers/analysis_handlers/sharing_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ def _unshare(self, analysis, user, callback):
def get(self):
analysis_id = int(self.get_argument('id'))
analysis = Analysis(analysis_id)
if self.current_user != analysis.owner and \
self.current_user not in analysis.shared_with:
if not analysis.has_access(self.current_user):
raise HTTPError(403, 'User %s does not have permissions to share '
'analysis %s' % (
self.current_user.id, analysis.id))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@

from unittest import main
from json import loads
from mock import Mock

from qiita_db.analysis import Analysis
from qiita_db.user import User
from qiita_pet.handlers.base_handlers import BaseHandler
from qiita_pet.test.tornado_test_base import TestHandlerBase


Expand Down Expand Up @@ -49,6 +51,15 @@ def test_get(self):
'Analysis <a href="/analysis/description/1">\'SomeAnalysis\'</a> '
'has been shared with you.', u.messages()[0][1])

# admins can share
BaseHandler.get_current_user = Mock(return_value=User("admin@foo.bar"))
args = {'deselected': u.id, 'id': a.id}
response = self.get('/analysis/sharing/', args)
self.assertEqual(response.code, 200)
exp = {'users': [], 'links': ''}
self.assertEqual(loads(response.body), exp)
self.assertEqual(a.shared_with, [])

def test_get_no_access(self):
args = {'selected': 'demo@microbio.me', 'id': 2}
response = self.get('/analysis/sharing/', args)
Expand Down