Merge pull request #3388 from ostcar/fix_3377
Fix PersonalNoteAccessPermissions for anonymous user
This commit is contained in:
commit
fcbe70f742
@ -186,12 +186,15 @@ 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.
|
||||||
for full in full_data:
|
if user is None:
|
||||||
if full['user_id'] == user.id:
|
|
||||||
data = [full]
|
|
||||||
break
|
|
||||||
else:
|
|
||||||
data = []
|
data = []
|
||||||
|
else:
|
||||||
|
for full in full_data:
|
||||||
|
if full['user_id'] == user.id:
|
||||||
|
data = [full]
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
data = []
|
||||||
|
|
||||||
# Reduce result to a single item or None if it was not a collection at
|
# Reduce result to a single item or None if it was not a collection at
|
||||||
# the beginning of the method.
|
# the beginning of the method.
|
||||||
|
@ -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)
|
||||||
|
Loading…
Reference in New Issue
Block a user