Enabled possibility to send null for motion poll votes vote value fields.
This commit is contained in:
parent
0cce7f967b
commit
19df7c82a2
@ -98,7 +98,7 @@ class MotionPollSerializer(ModelSerializer):
|
|||||||
no = SerializerMethodField()
|
no = SerializerMethodField()
|
||||||
abstain = SerializerMethodField()
|
abstain = SerializerMethodField()
|
||||||
votes = DictField(
|
votes = DictField(
|
||||||
child=IntegerField(min_value=-2),
|
child=IntegerField(min_value=-2, allow_null=True),
|
||||||
write_only=True)
|
write_only=True)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
@ -117,7 +117,7 @@ class MotionPollSerializer(ModelSerializer):
|
|||||||
def to_representation(self, obj):
|
def to_representation(self, obj):
|
||||||
"""
|
"""
|
||||||
Overrides the output of this serializer. Replaces vote values -1
|
Overrides the output of this serializer. Replaces vote values -1
|
||||||
through the translated string 'majority' and -2 or None through the
|
through the translated string 'majority' and -2 through the
|
||||||
translated string 'undocumented'.
|
translated string 'undocumented'.
|
||||||
"""
|
"""
|
||||||
result = super().to_representation(obj)
|
result = super().to_representation(obj)
|
||||||
@ -125,7 +125,7 @@ class MotionPollSerializer(ModelSerializer):
|
|||||||
if key in ('yes', 'no', 'abstain', 'votesvalid', 'votesinvalid', 'votescast'):
|
if key in ('yes', 'no', 'abstain', 'votesvalid', 'votesinvalid', 'votescast'):
|
||||||
if result[key] == -1:
|
if result[key] == -1:
|
||||||
result[key] = _('majority')
|
result[key] = _('majority')
|
||||||
elif result[key] == -2 or result[key] is None:
|
elif result[key] == -2:
|
||||||
result[key] = _('undocumented')
|
result[key] = _('undocumented')
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user