From cded1504f171572d21defd0eabe19a061f787f82 Mon Sep 17 00:00:00 2001 From: Yaron Dinur Date: Mon, 13 Mar 2017 20:20:28 +0200 Subject: [PATCH] added meeting to bill serializer --- committeeVotes/serializers.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/committeeVotes/serializers.py b/committeeVotes/serializers.py index 5e6c0dc..31f7a5a 100644 --- a/committeeVotes/serializers.py +++ b/committeeVotes/serializers.py @@ -69,6 +69,7 @@ class BillVoteSerializer(DynamicFieldsMixin, serializers.HyperlinkedModelSeriali nay = serializers.SerializerMethodField() sustained = serializers.SerializerMethodField() others = serializers.SerializerMethodField() + meeting = serializers.SerializerMethodField() def get_votes(self, bill, voteTypeName): voteType = VoteType.objects.get(typeName=voteTypeName) @@ -89,6 +90,12 @@ def get_other_ministers(self, bill): serializer = MinisterListSerializer(instance=qs, many=True) return serializer.data + def get_meeting(self, bill): + votes = Vote.objects.select_related('minister').filter(bill=bill) + meeting = votes[0].meeting if len(votes) > 0 else None + serializer = MeetingBillSerializer(instance=meeting) + return serializer.data + def get_yay(self, bill): return self.get_votes(bill, u'בעד') @@ -103,7 +110,7 @@ def get_others(self, bill): class Meta: model = Bill - fields = ('id', 'name', 'oknesset_url', 'passed', 'yay', 'nay', 'sustained', 'others') + fields = ('id', 'name', 'oknesset_url', 'passed', 'yay', 'nay', 'sustained', 'others', 'meeting') class MinisterSerializer(MinisterListSerializer):