Fixed changes in motion poll serializer.

This commit is contained in:
Norman Jäckel 2015-10-21 22:24:11 +02:00
parent 17973bae3d
commit 0fc915ec35

View File

@ -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):