Skip to content

Commit

Permalink
add vote endpoint in api
Browse files Browse the repository at this point in the history
  • Loading branch information
erivanio committed Dec 10, 2020
1 parent 393cf60 commit baa7052
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/api/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,25 @@ class Meta:
'id': ALL,
'agenda': ALL_WITH_RELATIONS,
}


class VoteResource(ModelResource):

agenda = fields.ToOneField(AgendaResource, 'agenda', full=True, null=True)
proposal = fields.ToOneField(ProposalResource, 'proposal',
full=True, null=True)
proposal_group = fields.ToOneField(ProposalGroupResource, 'proposal_group',
full=True, null=True)

class Meta:
queryset = models.Vote.objects.filter(agenda__is_visible=True)
allowed_methods = ['get']
filtering = {
'id': ALL,
'agenda': ALL_WITH_RELATIONS,
'proposal': ALL_WITH_RELATIONS,
'proposal_group': ALL_WITH_RELATIONS,
'datetime': ALL,
'vote': ALL,
}
ordering = ['datetime', 'vote']
1 change: 1 addition & 0 deletions src/api/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
v1_api.register(resources.ProposalResource())
v1_api.register(resources.ProposalGroupResource())
v1_api.register(resources.ProposalTypeResource())
v1_api.register(resources.VoteResource())

urlpatterns = [
url(r'^api/', include(v1_api.urls)),
Expand Down

0 comments on commit baa7052

Please sign in to comment.