From 0fc915ec35df06498a94a1b19fdfee7f2c24270c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Norman=20J=C3=A4ckel?= Date: Wed, 21 Oct 2015 22:24:11 +0200 Subject: [PATCH] Fixed changes in motion poll serializer. --- openslides/motions/serializers.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/openslides/motions/serializers.py b/openslides/motions/serializers.py index d9b5eee22..084428e48 100644 --- a/openslides/motions/serializers.py +++ b/openslides/motions/serializers.py @@ -106,13 +106,25 @@ class MotionPollSerializer(ModelSerializer): 'votes',) def get_yes(self, obj): - return obj.get_votes().get(value='Yes').weight + try: + result = obj.get_votes().get(value='Yes').weight + except obj.get_vote_class().DoesNotExist: + result = None + return result def get_no(self, obj): - return obj.get_votes().get(value='No').weight + try: + result = obj.get_votes().get(value='No').weight + except obj.get_vote_class().DoesNotExist: + result = None + return result def get_abstain(self, obj): - return obj.get_votes().get(value='Abstain').weight + try: + result = obj.get_votes().get(value='Abstain').weight + except obj.get_vote_class().DoesNotExist: + result = None + return result @transaction.atomic def update(self, instance, validated_data):