Skip to content

Commit

Permalink
added meeting to bill serializer
Browse files Browse the repository at this point in the history
  • Loading branch information
prsnca committed Mar 13, 2017
1 parent e7f3218 commit cded150
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion committeeVotes/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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'בעד')

Expand All @@ -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):
Expand Down

0 comments on commit cded150

Please sign in to comment.