Skip to content

Commit

Permalink
Global enable anonymous (#2660) (#2664)
Browse files Browse the repository at this point in the history
* Global enable anonymous

* Fix meeting.update

Co-authored-by: luisa-beerboom <101706784+luisa-beerboom@users.noreply.github.com>
  • Loading branch information
1 parent 960c976 commit 7202f1d
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 4 deletions.
4 changes: 3 additions & 1 deletion docs/actions/meeting.update.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@

// Group D
external_id: string;
enable_anonymous: boolean;
enable_anonymous: boolean
custom_translations: JSON;

// Group E
Expand Down Expand Up @@ -202,6 +202,8 @@ If `enable_anonymous` is set, this action will create an anonymous group for the

The meetings `anonymous_group_id` may not be used for the `assignment_poll_default_group_ids`, `topic_poll_default_group_ids` and `motion_poll_default_group_ids` fields.

`enable_anonymous` may only be set to true if `enable_anonymous` is set to true in the organization.

## Permissions
- Users with `meeting.can_manage_settings` can modify group A
- Users with `user.can_update` can modify group B
Expand Down
3 changes: 2 additions & 1 deletion docs/actions/organization.update.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@
// Group B
enable_electronic_voting: boolean;
enable_chat: boolean;
enable_anonymous: boolean;
reset_password_verbose_errors: boolean;
limit_of_meetings: int;
enable_chat: boolean;
saml_enabled: boolean;
saml_login_button_text: string;
saml_attr_mapping: JSON;
Expand Down
2 changes: 1 addition & 1 deletion global/meta
Submodule meta updated 1 files
+3 −0 models.yml
10 changes: 9 additions & 1 deletion openslides_backend/action/actions/meeting/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,16 @@ def update_instance(self, instance: dict[str, Any]) -> dict[str, Any]:
)
self.check_locking(instance, set_as_template)
organization = self.datastore.get(
ONE_ORGANIZATION_FQID, ["require_duplicate_from"], lock_result=False
ONE_ORGANIZATION_FQID,
["require_duplicate_from", "enable_anonymous"],
lock_result=False,
)
if instance.get("enable_anonymous") and not organization.get(
"enable_anonymous"
):
raise ActionException(
"Anonymous users can not be enabled in this organization."
)
if (
organization.get("require_duplicate_from")
and set_as_template is not None
Expand Down
1 change: 1 addition & 0 deletions openslides_backend/action/actions/organization/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class OrganizationUpdate(
group_B_fields = (
"enable_electronic_voting",
"enable_chat",
"enable_anonymous",
"reset_password_verbose_errors",
"limit_of_meetings",
"limit_of_users",
Expand Down
1 change: 1 addition & 0 deletions openslides_backend/models/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class Organization(Model):
required=True, constraints={"enum": ["en", "de", "it", "es", "ru", "cs", "fr"]}
)
require_duplicate_from = fields.BooleanField()
enable_anonymous = fields.BooleanField()
saml_enabled = fields.BooleanField()
saml_login_button_text = fields.CharField(default="SAML login")
saml_attr_mapping = fields.JSONField()
Expand Down
42 changes: 42 additions & 0 deletions tests/system/action/meeting/test_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class MeetingUpdateActionTest(BaseActionTestCase):
def setUp(self) -> None:
super().setUp()
self.test_models: dict[str, dict[str, Any]] = {
ONE_ORGANIZATION_FQID: {"enable_anonymous": True},
"committee/1": {"name": "test_committee"},
"meeting/1": {
"name": "test_name",
Expand Down Expand Up @@ -622,6 +623,7 @@ def test_update_with_user(self) -> None:
"""Also tests if the anonymous group is created"""
self.set_models(
{
ONE_ORGANIZATION_FQID: {"enable_anonymous": True},
"committee/1": {"meeting_ids": [3]},
"meeting/3": {
"is_active_in_organization_id": 1,
Expand Down Expand Up @@ -673,6 +675,46 @@ def test_update_with_user(self) -> None:
},
)

def test_update_anonymous_if_disabled_in_orga(self) -> None:
self.set_models(
{
"committee/1": {"meeting_ids": [3]},
"meeting/3": {
"is_active_in_organization_id": 1,
"committee_id": 1,
"group_ids": [11],
"admin_group_id": 11,
},
"group/11": {"meeting_id": 3, "admin_group_for_meeting_id": 3},
}
)
response = self.request_json(
[
{
"action": "meeting.update",
"data": [
{
"name": "meeting",
"welcome_title": "title",
"welcome_text": "",
"description": "",
"location": "",
"start_time": 1623016800,
"end_time": 1623016800,
"enable_anonymous": True,
"organization_tag_ids": [],
"id": 3,
}
],
},
]
)
self.assert_status_code(response, 400)
self.assertIn(
"Anonymous users can not be enabled in this organization.",
response.json["message"],
)

def test_update_set_as_template_true(self) -> None:
self.set_models(self.test_models)
response = self.request(
Expand Down
2 changes: 2 additions & 0 deletions tests/system/action/organization/test_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def test_update(self) -> None:
"name": "testtest",
"description": "blablabla",
"saml_attr_mapping": self.saml_attr_mapping,
"enable_anonymous": True,
},
)
self.assert_status_code(response, 200)
Expand All @@ -57,6 +58,7 @@ def test_update(self) -> None:
"name": "testtest",
"description": "blablabla",
"saml_attr_mapping": self.saml_attr_mapping,
"enable_anonymous": True,
},
)

Expand Down

0 comments on commit 7202f1d

Please sign in to comment.