Skip to content

Commit aff37c7

Browse files
authored
Add new required constraints (#3501)
1 parent 478eaa6 commit aff37c7

32 files changed

+196
-59
lines changed

openslides_backend/models/models.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1880,8 +1880,8 @@ class MotionChangeRecommendation(Model):
18801880
constraints={"enum": ["replacement", "insertion", "deletion", "other"]},
18811881
)
18821882
other_description = fields.CharField()
1883-
line_from = fields.IntegerField(constraints={"minimum": 0})
1884-
line_to = fields.IntegerField(constraints={"minimum": 0})
1883+
line_from = fields.IntegerField(required=True, constraints={"minimum": 0})
1884+
line_to = fields.IntegerField(required=True, constraints={"minimum": 0})
18851885
text = fields.HTMLStrictField()
18861886
creation_time = fields.TimestampField(read_only=True)
18871887
motion_id = fields.RelationField(
@@ -1897,7 +1897,7 @@ class MotionComment(Model):
18971897
verbose_name = "motion comment"
18981898

18991899
id = fields.IntegerField(required=True, constant=True)
1900-
comment = fields.HTMLStrictField()
1900+
comment = fields.HTMLStrictField(required=True)
19011901
motion_id = fields.RelationField(
19021902
to={"motion": "comment_ids"}, required=True, constant=True
19031903
)
@@ -2290,7 +2290,7 @@ class PersonalNote(Model):
22902290
to={"meeting_user": "personal_note_ids"}, required=True, constant=True
22912291
)
22922292
content_object_id = fields.GenericRelationField(
2293-
to={"motion": "personal_note_ids"}, constant=True
2293+
to={"motion": "personal_note_ids"}, required=True, constant=True
22942294
)
22952295
meeting_id = fields.RelationField(
22962296
to={"meeting": "personal_note_ids"}, required=True, constant=True
@@ -2495,7 +2495,7 @@ class Projector(Model):
24952495
verbose_name = "projector"
24962496

24972497
id = fields.IntegerField(required=True, constant=True)
2498-
name = fields.CharField()
2498+
name = fields.CharField(required=True)
24992499
is_internal = fields.BooleanField(default=False)
25002500
scale = fields.IntegerField(default=0)
25012501
scroll = fields.IntegerField(default=0, constraints={"minimum": 0})
@@ -2622,7 +2622,7 @@ class ProjectorMessage(Model):
26222622
verbose_name = "projector message"
26232623

26242624
id = fields.IntegerField(required=True, constant=True)
2625-
message = fields.HTMLStrictField()
2625+
message = fields.HTMLStrictField(required=True)
26262626
projection_ids = fields.RelationListField(
26272627
to={"projection": "content_object_id"},
26282628
on_delete=fields.OnDelete.CASCADE,
@@ -2779,7 +2779,7 @@ class Theme(Model):
27792779
accent_300 = fields.ColorField()
27802780
accent_400 = fields.ColorField()
27812781
accent_50 = fields.ColorField()
2782-
accent_500 = fields.ColorField(default="#2196f3")
2782+
accent_500 = fields.ColorField(required=True, default="#2196f3")
27832783
accent_600 = fields.ColorField()
27842784
accent_700 = fields.ColorField()
27852785
accent_800 = fields.ColorField()
@@ -2793,7 +2793,7 @@ class Theme(Model):
27932793
primary_300 = fields.ColorField()
27942794
primary_400 = fields.ColorField()
27952795
primary_50 = fields.ColorField()
2796-
primary_500 = fields.ColorField(default="#317796")
2796+
primary_500 = fields.ColorField(required=True, default="#317796")
27972797
primary_600 = fields.ColorField()
27982798
primary_700 = fields.ColorField()
27992799
primary_800 = fields.ColorField()
@@ -2807,7 +2807,7 @@ class Theme(Model):
28072807
warn_300 = fields.ColorField()
28082808
warn_400 = fields.ColorField()
28092809
warn_50 = fields.ColorField()
2810-
warn_500 = fields.ColorField(default="#f06400")
2810+
warn_500 = fields.ColorField(required=True, default="#f06400")
28112811
warn_600 = fields.ColorField()
28122812
warn_700 = fields.ColorField()
28132813
warn_800 = fields.ColorField()
@@ -2991,8 +2991,8 @@ class Vote(Model):
29912991
verbose_name = "vote"
29922992

29932993
id = fields.IntegerField(required=True, constant=True)
2994-
weight = fields.DecimalField(constant=True)
2995-
value = fields.CharField(constant=True)
2994+
weight = fields.DecimalField(required=True, constant=True)
2995+
value = fields.CharField(required=True, constant=True)
29962996
user_token = fields.CharField(required=True, constant=True)
29972997
option_id = fields.RelationField(
29982998
to={"option": "vote_ids"}, required=True, constant=True

tests/system/action/agenda_item/test_delete.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,23 +87,16 @@ def test_delete_with_projection(self) -> None:
8787
self.create_motion(20, 34)
8888
self.set_models(
8989
{
90-
"meeting/20": {
91-
"all_projection_ids": [1],
92-
},
9390
"agenda_item/111": {
9491
"content_object_id": "motion/34",
95-
"projection_ids": [1],
9692
"meeting_id": 20,
9793
},
9894
"projection/1": {
9995
"content_object_id": "agenda_item/111",
10096
"current_projector_id": 1,
10197
"meeting_id": 20,
10298
},
103-
"projector/1": {
104-
"current_projection_ids": [1],
105-
"meeting_id": 20,
106-
},
99+
"projector/1": {"meeting_id": 20, "name": "Projector 1"},
107100
}
108101
)
109102
response = self.request("agenda_item.delete", {"id": 111})

tests/system/action/assignment/test_delete.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,7 @@ def test_delete_correct_cascading(self) -> None:
6060
"current_projector_id": 1,
6161
"meeting_id": 110,
6262
},
63-
"projector/1": {
64-
"meeting_id": 110,
65-
},
63+
"projector/1": {"meeting_id": 110, "name": "Projector 1"},
6664
"assignment_candidate/1111": {"assignment_id": 111, "meeting_id": 110},
6765
}
6866
)

tests/system/action/list_of_speakers/test_delete.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@ def setUp(self) -> None:
2929
"current_projector_id": 1,
3030
"meeting_id": 78,
3131
},
32-
"projector/1": {
33-
"meeting_id": 78,
34-
},
32+
"projector/1": {"meeting_id": 78, "name": "main"},
3533
}
3634
)
3735

tests/system/action/mediafile/test_delete.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ def test_delete_check_relations(self) -> None:
164164
"current_projector_id": 1,
165165
"meeting_id": 111,
166166
},
167-
"projector/1": {"meeting_id": 111},
167+
"projector/1": {"meeting_id": 111, "name": "Projector 1"},
168168
}
169169
)
170170
response = self.request("mediafile.delete", {"id": 222})

tests/system/action/meeting/test_clone.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -632,12 +632,14 @@ def test_clone_missing_user_id_in_additional_users(self) -> None:
632632

633633
def test_clone_with_personal_note(self) -> None:
634634
self.set_test_data_with_admin()
635+
self.create_motion(1, 1)
635636
self.set_models(
636637
{
637638
"personal_note/1": {
638639
"note": "test note",
639640
"meeting_user_id": 1,
640641
"meeting_id": 1,
642+
"content_object_id": "motion/1",
641643
}
642644
}
643645
)
@@ -1679,13 +1681,17 @@ def test_clone_vote_delegated_vote(self) -> None:
16791681
"meeting_id": 1,
16801682
"option_id": 1,
16811683
"user_token": "asdfgh",
1684+
"weight": Decimal("1.000000"),
1685+
"value": "Y",
16821686
},
16831687
"vote/2": {
16841688
"user_id": 1,
16851689
"delegated_user_id": 1,
16861690
"meeting_id": 4,
16871691
"option_id": 2,
16881692
"user_token": "hjkl",
1693+
"weight": Decimal("1.000000"),
1694+
"value": "Y",
16891695
},
16901696
"option/1": {"meeting_id": 1},
16911697
"option/2": {"meeting_id": 4},

tests/system/action/meeting/test_import.py

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import base64
22
import time
33
from copy import deepcopy
4+
from decimal import Decimal
45
from typing import Any
56

67
from psycopg.types.json import Jsonb
@@ -2052,6 +2053,7 @@ def test_without_default_password(self) -> None:
20522053
assert "last_login" not in user
20532054

20542055
def test_merge_meeting_users_fields(self) -> None:
2056+
self.create_motion(1, 1)
20552057
self.set_models(
20562058
{
20572059
"user/14": {
@@ -2082,7 +2084,7 @@ def test_merge_meeting_users_fields(self) -> None:
20822084
"group/1": {"meeting_user_ids": [1, 14]},
20832085
"personal_note/1": {
20842086
"meeting_id": 1,
2085-
"content_object_id": None,
2087+
"content_object_id": "motion/1",
20862088
"note": "<p>Some content..</p>",
20872089
"star": False,
20882090
"meeting_user_id": 14,
@@ -2119,15 +2121,15 @@ def test_merge_meeting_users_fields(self) -> None:
21192121
"1": {
21202122
"id": 1,
21212123
"meeting_id": 1,
2122-
"content_object_id": None,
2124+
"content_object_id": "motion/2",
21232125
"note": "<p>Some content..</p>",
21242126
"star": False,
21252127
"meeting_user_id": 12,
21262128
},
21272129
"2": {
21282130
"id": 2,
21292131
"meeting_id": 1,
2130-
"content_object_id": None,
2132+
"content_object_id": "motion/2",
21312133
"note": "blablabla",
21322134
"star": False,
21332135
"meeting_user_id": 13,
@@ -2153,10 +2155,30 @@ def test_merge_meeting_users_fields(self) -> None:
21532155
"group_ids": [2],
21542156
},
21552157
},
2158+
"motion": {
2159+
"2": {
2160+
"id": 2,
2161+
"personal_note_ids": [1, 2],
2162+
"title": "New motion",
2163+
"meeting_id": 1,
2164+
"state_id": 1,
2165+
"list_of_speakers_id": 2,
2166+
}
2167+
},
2168+
"list_of_speakers": {
2169+
"2": {
2170+
"id": 2,
2171+
"content_object_id": "motion/2",
2172+
"meeting_id": 1,
2173+
}
2174+
},
21562175
}
21572176
)
21582177
request_data["meeting"]["meeting"]["1"]["personal_note_ids"] = [1, 2]
21592178
request_data["meeting"]["meeting"]["1"]["meeting_user_ids"] = [11, 12, 13]
2179+
request_data["meeting"]["meeting"]["1"]["motion_ids"] = [2]
2180+
request_data["meeting"]["meeting"]["1"]["list_of_speakers_ids"] = [2]
2181+
request_data["meeting"]["motion_state"]["1"]["motion_ids"] = [2]
21602182
request_data["meeting"]["group"]["2"]["meeting_user_ids"] = [12, 13]
21612183
response = self.request("meeting.import", request_data)
21622184
self.assert_status_code(response, 200)
@@ -2305,6 +2327,8 @@ def test_import_new_user_with_vote(self) -> None:
23052327
"meeting_id": 1,
23062328
"option_id": 10,
23072329
"user_token": "asdfgh",
2330+
"weight": Decimal("1.000000"),
2331+
"value": "Y",
23082332
},
23092333
"option/10": {
23102334
"vote_ids": [1],
@@ -2326,6 +2350,8 @@ def test_import_new_user_with_vote(self) -> None:
23262350
"meeting_id": 1,
23272351
"option_id": 1,
23282352
"user_token": "asdfgh",
2353+
"weight": "1.000000",
2354+
"value": "Y",
23292355
},
23302356
},
23312357
"option": {
@@ -2508,6 +2534,8 @@ def test_import_existing_user_with_vote(self) -> None:
25082534
"meeting_id": 1,
25092535
"option_id": 10,
25102536
"user_token": "asdfgh",
2537+
"weight": Decimal("1.000000"),
2538+
"value": "Y",
25112539
},
25122540
"option/10": {
25132541
"vote_ids": [1],
@@ -2529,6 +2557,8 @@ def test_import_existing_user_with_vote(self) -> None:
25292557
"meeting_id": 1,
25302558
"option_id": 1,
25312559
"user_token": "asdfgh",
2560+
"weight": "1.000000",
2561+
"value": "Y",
25322562
},
25332563
},
25342564
"option": {

tests/system/action/meeting/test_replace_projector_id.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def setUp(self) -> None:
1111
"projector/1": {
1212
"used_as_default_projector_for_motion_in_meeting_id": 1
1313
},
14-
"projector/20": {"meeting_id": 1},
14+
"projector/20": {"meeting_id": 1, "name": "Projector 20"},
1515
}
1616
)
1717

tests/system/action/motion/test_delete.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,12 @@ def test_delete_with_submodels(self) -> None:
166166
"motion_id": 111,
167167
"meeting_user_id": 1,
168168
},
169-
"motion_change_recommendation/1": {"meeting_id": 1, "motion_id": 111},
169+
"motion_change_recommendation/1": {
170+
"meeting_id": 1,
171+
"motion_id": 111,
172+
"line_from": 14,
173+
"line_to": 15,
174+
},
170175
}
171176
)
172177
response = self.request("motion.delete", {"id": 111})

0 commit comments

Comments
 (0)