democrasite.webiscite.views module¶
Views for the webiscite app.
- class democrasite.webiscite.views.BillDetailView(**kwargs)¶
Bases:
DetailViewView for one bill on its own page.
- get_object(queryset=None)¶
Return the object the view is displaying.
Require self.queryset and a pk or slug argument in the URLconf. Subclasses can override this to return any object.
- class democrasite.webiscite.views.BillListView(**kwargs)¶
Bases:
ListViewView listing all open bills. Used for webiscite:index.
- get_context_data(**kwargs)¶
Get the context for this view.
- get_queryset()¶
Return the list of items for this view.
The return value must be an iterable and may be an instance of QuerySet in which case QuerySet specific behavior will be enabled.
- class democrasite.webiscite.views.BillProposalsView(**kwargs)¶
Bases:
LoginRequiredMixin,ListViewView for listing bills proposed by the current user.
- get_context_data(**kwargs)¶
Get the context for this view.
- get_queryset()¶
Return the list of items for this view - bills proposed by the current user.
- class democrasite.webiscite.views.BillUpdateView(**kwargs)¶
Bases:
UserPassesTestMixin,SuccessMessageMixin,UpdateViewView for updating a bill’s name and description on Democrasite
- fields = ['name', 'description']¶
- success_message = 'Information successfully updated'¶
- test_func()¶
- class democrasite.webiscite.views.BillVotesView(**kwargs)¶
Bases:
LoginRequiredMixin,ListViewView for listing bills voted on by the current user.
- get_context_data(**kwargs)¶
Get the context for this view.
- get_queryset()¶
Return the list of items for this view - bills voted on by the current user.
- democrasite.webiscite.views.bill_detail_view(request, *args, **kwargs)¶
View for one bill on its own page.
- democrasite.webiscite.views.bill_list_view(request, *args, **kwargs)¶
View listing all open bills. Used for webiscite:index.
- democrasite.webiscite.views.bill_proposals_view(request, *args, **kwargs)¶
View for listing bills proposed by the current user.
- democrasite.webiscite.views.bill_update_view(request, *args, **kwargs)¶
View for updating a bill’s name and description on Democrasite
- democrasite.webiscite.views.bill_votes_view(request, *args, **kwargs)¶
View for listing bills voted on by the current user.
- democrasite.webiscite.views.vote_view(request: HttpRequest, pk: int) HttpResponse¶
View for ajax request made when a user votes on a bill
Validates that vote is valid and, if so, registers it with the database and returns an HttpResponse containing a JSON object listing the number of yes and no votes on that bill.
- Parameters:
request – The request from the client
pk – The id of the bill being voted on
- Returns:
A JsonResponse containing the vote counts for the bill if the request was valid, otherwise a client error response
- Return type:
HttpResponse