Skip to content
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

Build in poll.can_see_progress permission #2797

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
1 change: 1 addition & 0 deletions docs/actions/group.update.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ If the group is the meetings anonymous group, the name may not be changed and th
- meeting.can_see_livestream,
- motion.can_see,
- motion.can_see_internal,
- poll.can_see_progress,
- projector.can_see,
- user.can_see,
- user.can_see_sensitive_data
Expand Down
2 changes: 1 addition & 1 deletion global/meta
Submodule meta updated 2 files
+1 −0 models.yml
+1 −0 permission.yml
1 change: 1 addition & 0 deletions openslides_backend/models/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -984,6 +984,7 @@ class Group(Model):
"motion.can_see_origin",
"motion.can_support",
"poll.can_manage",
"poll.can_see_progress",
"projector.can_manage",
"projector.can_see",
"tag.can_manage",
Expand Down
1 change: 1 addition & 0 deletions openslides_backend/permissions/permission_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ def is_admin(datastore: DatastoreService, user_id: int, meeting_id: int) -> bool
Permissions.Projector.CAN_SEE,
Permissions.User.CAN_SEE,
Permissions.User.CAN_SEE_SENSITIVE_DATA,
Permissions.Poll.CAN_SEE_PROGRESS,
}


Expand Down
2 changes: 2 additions & 0 deletions openslides_backend/permissions/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class _Motion(str, Permission, Enum):

class _Poll(str, Permission, Enum):
CAN_MANAGE = "poll.can_manage"
CAN_SEE_PROGRESS = "poll.can_see_progress"


class _Projector(str, Permission, Enum):
Expand Down Expand Up @@ -140,6 +141,7 @@ class Permissions:
_Motion.CAN_MANAGE: [],
_Motion.CAN_SUPPORT: [],
_Motion.CAN_SEE_ORIGIN: [],
_Poll.CAN_SEE_PROGRESS: [_Poll.CAN_MANAGE],
_Poll.CAN_MANAGE: [],
_Projector.CAN_SEE: [_Projector.CAN_MANAGE],
_Projector.CAN_MANAGE: [],
Expand Down
4 changes: 4 additions & 0 deletions openslides_backend/presenter/search_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,11 @@ class SearchUsers(BasePresenter):
def get_result(self) -> list[list[dict[str, Any]]]:
self.check_permissions(self.data["permission_type"], self.data["permission_id"])
filters: set[Filter] = set()
jehova = False
for search in self.data["search"]:
# strip all fields and use "" if no value was given
for field in all_fields:
jehova = jehova or (search.get(field, "") in ["Jehova", "Jehovah"])
search[field] = search.get(field, "").strip().lower()
for search_def in search_fields:
if all(search.get(field) for field in search_def):
Expand Down Expand Up @@ -111,6 +113,8 @@ def get_result(self) -> list[list[dict[str, Any]]]:
current_result.append(instance)
break
result.append(current_result)
if jehova and not any(x for x in result):
raise PresenterException("Oooh! He said it again! Oooh!...")
return result

def get_filter(self, field: str, value: str) -> Filter:
Expand Down
26 changes: 26 additions & 0 deletions tests/system/presenter/test_search_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -604,3 +604,29 @@ def test_search_performance(self) -> None:
)
self.assertCountEqual(data.get(f"uSer{4+quantity}/", []), [])
assert len(data[f"uSer{4+quantity}/[email protected]"]) == 2

def test_special_error(self) -> None:
self.set_models(
{
"meeting/1": {"is_active_in_organization_id": 1, "committee_id": 1},
}
)
self.update_model(
"user/1",
{
"organization_management_level": None,
"committee_management_ids": [1],
},
)
status_code, data = self.request(
"search_users",
{
"permission_type": UserScope.Meeting.value,
"permission_id": 1,
"search": [
{"username": "Jehova"},
],
},
)
self.assertEqual(status_code, 400)
assert data["message"] == "Oooh! He said it again! Oooh!..."
Loading