democrasite.webiscite.managers module¶
Managers for the webiscite app models.
- class democrasite.webiscite.managers.BillManager(*args, **kwargs)¶
-
- annotate_user_vote(user: User, queryset: QuerySet | None = None)¶
Annotate a queryset with the given user’s vote on each bill.
- Parameters:
user – The user whose vote to annotate
queryset – The queryset to annotate; defaults to
self.get_queryset()
- Returns:
The queryset annotated with a
user_votefield (True/False/None)
- create_from_github(pull_request: PullRequest, desc: str, author_uid: str) T | None¶
Validate and create a
Billfrom a GitHub pull request- Parameters:
pull_request – The pull request instance to associate with the bill
desc – The description of the bill (pull request body)
author_uid – The GitHub UID of the pull request author
- Returns:
The new bill instance, or None if the author has no linked account
- get_queryset()¶
Return a queryset with related models pre-fetched and vote amounts added.
All Bill querysets include
total_votes,yes_count,yes_percent,no_countandno_percentannotations, prefetch pull_request and author, and are ordered by creation date.