Skip to content

Commit

Permalink
set vote_weight to "0.000001" in meeting.clone (#2006)
Browse files Browse the repository at this point in the history
  • Loading branch information
r-peschke authored Nov 21, 2023
1 parent bb446a8 commit 61c1ce6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
7 changes: 7 additions & 0 deletions openslides_backend/action/actions/meeting/clone.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import time
from decimal import Decimal
from typing import Any, Dict, List, cast

from openslides_backend.models.checker import (
Expand Down Expand Up @@ -110,6 +111,12 @@ def update_instance(self, instance: Dict[str, Any]) -> Dict[str, Any]:
if field in instance:
meeting[field] = instance.pop(field)

for mu in meeting_json.get("meeting_user", {}).values():
if (value := mu.get("vote_weight")) and Decimal(value) == Decimal(
"0.000000"
):
mu["vote_weight"] = "0.000001"

# check datavalidation
checker = Checker(
data=meeting_json,
Expand Down
17 changes: 15 additions & 2 deletions tests/system/action/meeting/test_clone.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ def test_clone_with_users(self) -> None:
"meeting_id": 1,
"user_id": 1,
"group_ids": [1],
"vote_weight": "0.000000",
},
}
)
Expand All @@ -158,10 +159,22 @@ def test_clone_with_users(self) -> None:
},
)
self.assert_model_exists(
"meeting_user/1", {"meeting_id": 1, "user_id": 1, "group_ids": [1]}
"meeting_user/1",
{
"meeting_id": 1,
"user_id": 1,
"group_ids": [1],
"vote_weight": "0.000000",
},
)
self.assert_model_exists(
"meeting_user/2", {"meeting_id": 2, "user_id": 1, "group_ids": [3]}
"meeting_user/2",
{
"meeting_id": 2,
"user_id": 1,
"group_ids": [3],
"vote_weight": "0.000001",
},
)

def test_clone_with_ex_users(self) -> None:
Expand Down

0 comments on commit 61c1ce6

Please sign in to comment.