democrasite.webiscite.models module¶
Models for the webiscite app
- class democrasite.webiscite.models.Bill(*args, **kwargs)¶
Bases:
TimeStampedModelModel for a proposal to merge a particular pull request into the main branch
- Parameters:
id (BigAutoField) – Primary key: ID
created (AutoCreatedField) – Created
modified (AutoLastModifiedField) – Modified
name (CharField) – Name
description (TextField) – Description
status (CharField) – Status. The current status of the bill
constitutional (BooleanField) – Constitutional. True if this bill is an amendment to the constitution
Relationship fields:
- Parameters:
author (
ForeignKeytoUser) – Author (related name:bill)pull_request (
ForeignKeytoPullRequest) – Pull request (related name:bill)_submit_task (
OneToOneFieldtoPeriodicTask) – submit task (related name:bill)votes (
ManyToManyFieldtoUser) – Votes (related name:votes)
Reverse relationships:
- Parameters:
vote (Reverse
ForeignKeyfromVote) – All votes of this bill (related name ofbill)
- exception DoesNotExist¶
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned¶
Bases:
MultipleObjectsReturned
- author¶
Type:
ForeignKeytoUserAuthor (related name:
bill)Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
- constitutional¶
Type:
BooleanFieldConstitutional. True if this bill is an amendment to the constitution
A wrapper for a deferred-loading field. When the value is read from this
- created¶
Type:
AutoCreatedFieldCreated
A wrapper for a deferred-loading field. When the value is read from this
- description¶
Type:
TextFieldDescription
A wrapper for a deferred-loading field. When the value is read from this
- get_next_by_created(*, field=<model_utils.fields.AutoCreatedField: created>, is_next=True, **kwargs)¶
Finds next instance based on
created. Seeget_next_by_FOO()for more information.
- get_next_by_modified(*, field=<model_utils.fields.AutoLastModifiedField: modified>, is_next=True, **kwargs)¶
Finds next instance based on
modified. Seeget_next_by_FOO()for more information.
- get_previous_by_created(*, field=<model_utils.fields.AutoCreatedField: created>, is_next=False, **kwargs)¶
Finds previous instance based on
created. Seeget_previous_by_FOO()for more information.
- get_previous_by_modified(*, field=<model_utils.fields.AutoLastModifiedField: modified>, is_next=False, **kwargs)¶
Finds previous instance based on
modified. Seeget_previous_by_FOO()for more information.
- get_status_display(*, field=<django.db.models.CharField: status>)¶
Shows the label of the
status. Seeget_FOO_display()for more information.
- history = <django.db.models.manager.HistoryManagerFromHistoricalQuerySet object>¶
- id¶
Type:
BigAutoFieldPrimary key: ID
A wrapper for a deferred-loading field. When the value is read from this
- log(msg, *args, level=20)¶
- modified¶
Type:
AutoLastModifiedFieldModified
A wrapper for a deferred-loading field. When the value is read from this
- no_count = 0¶
- no_percent = 0¶
- objects = <democrasite.webiscite.managers.BillManager object>¶
- pull_request¶
Type:
ForeignKeytoPullRequestPull request (related name:
bill)Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
- pull_request_id¶
Internal field, use
pull_requestinstead.
- save(*args, **kwargs)¶
Overriding the save method in order to make sure that modified field is updated even if it is not given as a parameter to the update field argument.
- save_without_historical_record(*args, **kwargs)¶
Save the model instance without creating a historical record.
Make sure you know what you’re doing before using this method.
- status¶
Type:
CharFieldStatus. The current status of the bill
Choices:
draftopenapprovedamendedrejectedfailedclosed
- total_votes = 0¶
- user_supports(user: User) bool | None¶
Returns whether the given user supports, opposes, or has not voted on this bill
- Parameters:
user – The user to check
- Returns:
True if the user supports the bill, False if they oppose it, and None if they have not voted
- vote(user: User, *, support: bool) None¶
Sets the given user’s vote based on the support parameter
If the user already voted the way the method would set, their vote is removed from the bill (i.e. if the user previously voted yes and support is
True, their vote is removed)- Parameters:
- Raises:
ClosedBillVoteError – If the bill is not open for voting
- vote_set¶
Type: Reverse
ForeignKeyfromVoteAll votes of this bill (related name of
bill)Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Parent.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager
- votes¶
Type:
ManyToManyFieldtoUserVotes (related name:
votes)Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.
In the example:
class Pizza(Model): toppings = ManyToManyField(Topping, related_name='pizzas')
Pizza.toppingsandTopping.pizzasareManyToManyDescriptorinstances.Most of the implementation is delegated to a dynamically defined manager
- yes_count = 0¶
- yes_percent = 0¶
- class democrasite.webiscite.models.PullRequest(*args, **kwargs)¶
Bases:
TimeStampedModelLocal representation of a pull request on Github
- Parameters:
created (AutoCreatedField) – Created
modified (AutoLastModifiedField) – Modified
number (IntegerField) – Primary key: Pull request number
title (CharField) – Title
additions (IntegerField) – Additions. Lines added
deletions (IntegerField) – Deletions. Lines removed
diff_url (URLField) – Diff url. URL to the diff of the pull request
author_name (CharField) – Author name
draft (BooleanField) – Draft. Whether the pull request is a draft on GitHub
status (CharField) – Status. State of the PR on Github
sha (CharField) – Sha. Unique identifier of PR commit
Reverse relationships:
- Parameters:
bill (Reverse
ForeignKeyfromBill) – All bills of this pull request (related name ofpull_request)
- exception DoesNotExist¶
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned¶
Bases:
MultipleObjectsReturned
- additions¶
Type:
IntegerFieldAdditions. Lines added
A wrapper for a deferred-loading field. When the value is read from this
- author_name¶
Type:
CharFieldAuthor name
A wrapper for a deferred-loading field. When the value is read from this
- bill_set¶
Type: Reverse
ForeignKeyfromBillAll bills of this pull request (related name of
pull_request)Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Parent.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager
- close() Bill | None¶
Mark the pull request and the associated bill closed if it was open
- Parameters:
pr_num – The number of the pull request to close
- Returns:
The bill associated with the pull request, if it was open
- created¶
Type:
AutoCreatedFieldCreated
A wrapper for a deferred-loading field. When the value is read from this
- deletions¶
Type:
IntegerFieldDeletions. Lines removed
A wrapper for a deferred-loading field. When the value is read from this
- diff_url¶
Type:
URLFieldDiff url. URL to the diff of the pull request
A wrapper for a deferred-loading field. When the value is read from this
- draft¶
Type:
BooleanFieldDraft. Whether the pull request is a draft on GitHub
A wrapper for a deferred-loading field. When the value is read from this
- get_next_by_created(*, field=<model_utils.fields.AutoCreatedField: created>, is_next=True, **kwargs)¶
Finds next instance based on
created. Seeget_next_by_FOO()for more information.
- get_next_by_modified(*, field=<model_utils.fields.AutoLastModifiedField: modified>, is_next=True, **kwargs)¶
Finds next instance based on
modified. Seeget_next_by_FOO()for more information.
- get_previous_by_created(*, field=<model_utils.fields.AutoCreatedField: created>, is_next=False, **kwargs)¶
Finds previous instance based on
created. Seeget_previous_by_FOO()for more information.
- get_previous_by_modified(*, field=<model_utils.fields.AutoLastModifiedField: modified>, is_next=False, **kwargs)¶
Finds previous instance based on
modified. Seeget_previous_by_FOO()for more information.
- get_status_display(*, field=<django.db.models.CharField: status>)¶
Shows the label of the
status. Seeget_FOO_display()for more information.
- history = <django.db.models.manager.HistoryManagerFromHistoricalQuerySet object>¶
- log(msg, *args, level=20)¶
- modified¶
Type:
AutoLastModifiedFieldModified
A wrapper for a deferred-loading field. When the value is read from this
- number¶
Type:
IntegerFieldPrimary key: Pull request number
A wrapper for a deferred-loading field. When the value is read from this
- objects = <democrasite.webiscite.managers.PullRequestManager object>¶
- save_without_historical_record(*args, **kwargs)¶
Save the model instance without creating a historical record.
Make sure you know what you’re doing before using this method.
- class democrasite.webiscite.models.Vote(*args, **kwargs)¶
Bases:
ModelA vote for or against a bill, with a timestamp
- Parameters:
id (BigAutoField) – Primary key: ID
support (BooleanField) – Support
when (DateTimeField) – When
Relationship fields:
- Parameters:
bill (
ForeignKeytoBill) – Bill (related name:vote)user (
ForeignKeytoUser) – User (related name:vote)
- exception DoesNotExist¶
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned¶
Bases:
MultipleObjectsReturned
- bill¶
Type:
ForeignKeytoBillBill (related name:
vote)Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
- get_next_by_when(*, field=<django.db.models.DateTimeField: when>, is_next=True, **kwargs)¶
Finds next instance based on
when. Seeget_next_by_FOO()for more information.
- get_previous_by_when(*, field=<django.db.models.DateTimeField: when>, is_next=False, **kwargs)¶
Finds previous instance based on
when. Seeget_previous_by_FOO()for more information.
- history = <django.db.models.manager.HistoryManagerFromHistoricalQuerySet object>¶
- id¶
Type:
BigAutoFieldPrimary key: ID
A wrapper for a deferred-loading field. When the value is read from this
- objects = <django.db.models.Manager object>¶
- save_without_historical_record(*args, **kwargs)¶
Save the model instance without creating a historical record.
Make sure you know what you’re doing before using this method.
- support¶
Type:
BooleanFieldSupport
A wrapper for a deferred-loading field. When the value is read from this
- user¶
Type:
ForeignKeytoUserUser (related name:
vote)Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
- when¶
Type:
DateTimeFieldWhen
A wrapper for a deferred-loading field. When the value is read from this