Fixed changes in motion poll serializer.
This commit is contained in:
parent
17973bae3d
commit
0fc915ec35
@ -106,13 +106,25 @@ class MotionPollSerializer(ModelSerializer):
|
|||||||
'votes',)
|
'votes',)
|
||||||
|
|
||||||
def get_yes(self, obj):
|
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):
|
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):
|
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
|
@transaction.atomic
|
||||||
def update(self, instance, validated_data):
|
def update(self, instance, validated_data):
|
||||||
|
Loading…
Reference in New Issue
Block a user