From 7bb579dfe84ed5e03e996901e7ae59669be1bc41 Mon Sep 17 00:00:00 2001 From: reiterl Date: Wed, 16 Aug 2023 11:38:43 +0200 Subject: [PATCH] Fix delete user with poll candidate (#1872) --- global/meta/models.yml | 1 - openslides_backend/models/models.py | 4 ++-- tests/system/action/user/test_delete.py | 20 ++++++++++++++++++++ 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/global/meta/models.yml b/global/meta/models.yml index fad95ba40..9eeaaca55 100644 --- a/global/meta/models.yml +++ b/global/meta/models.yml @@ -3286,7 +3286,6 @@ poll_candidate: user_id: type: relation to: user/poll_candidate_ids - required: true restriction_mode: A weight: type: number diff --git a/openslides_backend/models/models.py b/openslides_backend/models/models.py index b7df919c7..5e2703159 100644 --- a/openslides_backend/models/models.py +++ b/openslides_backend/models/models.py @@ -3,7 +3,7 @@ from openslides_backend.models import fields from openslides_backend.models.base import Model -MODELS_YML_CHECKSUM = "6faa8e76b0382398e24bb2d4b7fdd0ae" +MODELS_YML_CHECKSUM = "9ace09287ef7c4a9856f8d2583f21d60" class Organization(Model): @@ -1756,7 +1756,7 @@ class PollCandidate(Model): required=True, equal_fields="meeting_id", ) - user_id = fields.RelationField(to={"user": "poll_candidate_ids"}, required=True) + user_id = fields.RelationField(to={"user": "poll_candidate_ids"}) weight = fields.IntegerField(required=True) meeting_id = fields.RelationField( to={"meeting": "poll_candidate_ids"}, required=True diff --git a/tests/system/action/user/test_delete.py b/tests/system/action/user/test_delete.py index 285b0c811..0813a7d83 100644 --- a/tests/system/action/user/test_delete.py +++ b/tests/system/action/user/test_delete.py @@ -143,6 +143,26 @@ def test_delete_with_submitter(self) -> None: ) self.assert_model_exists("motion/50", {"submitter_ids": []}) + def test_delete_with_poll_candidate(self) -> None: + self.set_models( + { + "user/111": { + "username": "username_srtgb123", + "poll_candidate_ids": [34], + }, + "meeting/1": {}, + "poll_candidate/34": {"user_id": 111}, + } + ) + response = self.request("user.delete", {"id": 111}) + + self.assert_status_code(response, 200) + self.assert_model_deleted( + "user/111", + {"poll_candidate_ids": [34]}, + ) + self.assert_model_exists("poll_candidate/34", {"user_id": None}) + def test_delete_with_template_field_set_null(self) -> None: self.set_models( {