signoffs.core.models.managers#
Custom object and query managers.
Module Contents#
Classes#
Delegates common methods to a query manager or queryset to emulate a queryset-like API, without making extra queries where possible. Assumes a small number of instances on the queryset |
|
Delegates common methods to a signet_set manager or queryset |
|
Manage a set of Signoff objects backed by a signet manager or queryset. May be used, for example, on the reverse side of a many-to-one relation formed by a Signet with a FK. |
|
A SignoffSetManager that attempts to limit the number of related signets to one and provide simplified API for dealing with the single signoff. Why? b/c it is convenient to manage all signoffs, e.g., on an Approval, backed by one Signet model. If every Signoff is a single, then a set of SignoffFields is well-suited to the task. But if any Signoff may be a series, then it is convenient to model all as SignoffSets. This class helps clarify that a specific reverse Many2One relation is being modeled as a OneToOne. Caveats Canāt really prevent multiple signoffs being added via non-API access. Thatās up to the application programmer. |
|
Manage the entire set of signoffs related to a Stamp of Approval via reverse signet_set manager. Note that a single Stamp manages one set of Signets that may be of various Signoff Types - recommend using a SignoffSetManager instead, unless access to entire set of signoffs is needed. Provides a unified API for accessing a single Stamp instanceās related signoffs and signets. |
|
Delegates common methods to a stamp_set manager or queryset |
|
Manage a set of Approval objects backed by a Stamp manager or queryset. May be used, for example, on the reverse side of a many-to-one relation formed by a Stamp with a FK. Provides a unified API for accessing Approval instances, and related SigningOrder, Stamp, signoffs, and signets. |
API#
- class signoffs.core.models.managers.QuerySetApiMixin[source]#
Delegates common methods to a query manager or queryset to emulate a queryset-like API, without making extra queries where possible. Assumes a small number of instances on the queryset
- qs#
None
- class signoffs.core.models.managers.SignetSetApiMixin[source]#
Bases:
signoffs.core.models.managers.QuerySetApiMixinDelegates common methods to a signet_set manager or queryset
- signet_set#
None
- property qs#
- class signoffs.core.models.managers.SignoffSetManager(signoff_type, signet_set, signet_set_owner=None)[source]#
Bases:
signoffs.core.models.managers.SignetSetApiMixinManage a set of Signoff objects backed by a signet manager or queryset. May be used, for example, on the reverse side of a many-to-one relation formed by a Signet with a FK.
For example::
signets = Signets.objects.filter(user=bob) bobs_report_signoffs = SignoffSetManager('myapp.signoffs.report', signets)For āreverseā access from a signet-related object, use a SignoffSet field to define the reverse manager.
The API is modelled on djangoās related object managers, with familiar operations that work roughly equivalently.
Initialization
Manage the signet_set (query manager or queryset), filtered for the given Signoff Type If an approval instance is supplied, signets in this set are created with a reference to the approvalās stamp.
- _pre_save_owner()[source]#
Bit of a hack - if signet_set_owner is an unsaved model, save it before saving related signets
- can_sign(user)[source]#
Return True iff given user would be allowed to sign (create) a new signoff in this set
- property forms#
Return the forms manager for adding a new signoff to this set or revoking a signoff in this set.
- class signoffs.core.models.managers.SignoffSingleManager(signoff_type, signet_set, signet_set_owner=None)[source]#
Bases:
signoffs.core.models.managers.SignoffSetManagerA SignoffSetManager that attempts to limit the number of related signets to one and provide simplified API for dealing with the single signoff. Why? b/c it is convenient to manage all signoffs, e.g., on an Approval, backed by one Signet model. If every Signoff is a single, then a set of SignoffFields is well-suited to the task. But if any Signoff may be a series, then it is convenient to model all as SignoffSets. This class helps clarify that a specific reverse Many2One relation is being modeled as a OneToOne. Caveats Canāt really prevent multiple signoffs being added via non-API access. Thatās up to the application programmer.
Initialization
Manage the signet_set (query manager or queryset), filtered for the given Signoff Type If an approval instance is supplied, signets in this set are created with a reference to the approvalās stamp.
- class signoffs.core.models.managers.StampSignoffsManager(stamp, subject=None)[source]#
Bases:
signoffs.core.models.managers.SignetSetApiMixinManage the entire set of signoffs related to a Stamp of Approval via reverse signet_set manager. Note that a single Stamp manages one set of Signets that may be of various Signoff Types - recommend using a SignoffSetManager instead, unless access to entire set of signoffs is needed. Provides a unified API for accessing a single Stamp instanceās related signoffs and signets.
For example::
stamp = ProjectStamp.objects.filter(project_id='bob').first() bobs_project_signoffs = StampSignoffsManager(stamp)
The API is modelled on djangoās related object managers, with familiar operations that work roughly equivalently.
Initialization
Manage the given Approval instance and all of its related data
- property signet_set#
required for SignetSetApiMixin
- class signoffs.core.models.managers.ApprovalStampSetApiMixin[source]#
Bases:
signoffs.core.models.managers.QuerySetApiMixinDelegates common methods to a stamp_set manager or queryset
- stamp_set#
None
- property qs#
- class signoffs.core.models.managers.ApprovalSetManager(approval_type, stamp_set, subject=None)[source]#
Bases:
signoffs.core.models.managers.ApprovalStampSetApiMixinManage a set of Approval objects backed by a Stamp manager or queryset. May be used, for example, on the reverse side of a many-to-one relation formed by a Stamp with a FK. Provides a unified API for accessing Approval instances, and related SigningOrder, Stamp, signoffs, and signets.
For example::
stamps = Stamp.objects.filter(user=bob) bobs_report_approvals = ApprovalSetManager('myapp.approvals.report', stamps)For āreverseā access from a stamp-related object, use an ApprovalSet field to define the reverse manager.
The API is modelled on djangoās related object managers, with familiar operations that work roughly equivalently.
Initialization
Manage the stamp_set (query manager or queryset), filtered for the given Signoff Type