Skip to content

Commit

Permalink
Fix delete user with poll candidate (#1872)
Browse files Browse the repository at this point in the history
  • Loading branch information
reiterl authored Aug 16, 2023
1 parent 7b4a296 commit 7bb579d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
1 change: 0 additions & 1 deletion global/meta/models.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3286,7 +3286,6 @@ poll_candidate:
user_id:
type: relation
to: user/poll_candidate_ids
required: true
restriction_mode: A
weight:
type: number
Expand Down
4 changes: 2 additions & 2 deletions openslides_backend/models/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down
20 changes: 20 additions & 0 deletions tests/system/action/user/test_delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
{
Expand Down

0 comments on commit 7bb579d

Please sign in to comment.