Merge pull request #3388 from ostcar/fix_3377

Fix PersonalNoteAccessPermissions for anonymous user
This commit is contained in:
Norman Jäckel 2017-09-01 20:33:59 +02:00 committed by GitHub
commit fcbe70f742
2 changed files with 34 additions and 6 deletions

View File

@ -186,6 +186,9 @@ class PersonalNoteAccessPermissions(BaseAccessPermissions):
full_data = container.get_full_data() if isinstance(container, Collection) else [container.get_full_data()] full_data = container.get_full_data() if isinstance(container, Collection) else [container.get_full_data()]
# Parse data. # Parse data.
if user is None:
data = []
else:
for full in full_data: for full in full_data:
if full['user_id'] == user.id: if full['user_id'] == user.id:
data = [full] data = [full]

View File

@ -1,6 +1,9 @@
from unittest import TestCase from unittest import TestCase
from openslides.users.access_permissions import UserAccessPermissions from openslides.users.access_permissions import (
PersonalNoteAccessPermissions,
UserAccessPermissions,
)
from openslides.utils.collection import CollectionElement from openslides.utils.collection import CollectionElement
@ -37,3 +40,25 @@ class UserGetProjectorDataTest(TestCase):
'is_present': False, 'is_present': False,
'is_committee': False, 'is_committee': False,
}) })
class TestPersonalNoteAccessPermissions(TestCase):
def test_get_restricted_data(self):
ap = PersonalNoteAccessPermissions()
rd = ap.get_restricted_data(
CollectionElement.from_values(
'users/personal_note',
1,
full_data={'user_id': 1}),
CollectionElement.from_values('users/user', 5, full_data={}))
self.assertEqual(rd, None)
def test_get_restricted_data_for_anonymous(self):
ap = PersonalNoteAccessPermissions()
rd = ap.get_restricted_data(
CollectionElement.from_values(
'users/personal_note',
1,
full_data={'user_id': 1}),
None)
self.assertEqual(rd, None)