signoffs.core.models.signets#
A Signet is a relation between a user and a timestamp.
A concrete Signet may have other information about, or perhaps a relation to, the thing being signed off.
A Signet records a one-time action that can generally only be completed by a User with permission.
The presence of a Signet record provides evidence that a particular someone signed off on a particular something.
A Signet is not intended to be edited. Create them, revoke them, re-create them. Don’t edit and re-save them.
To revoke a Signet, we can simply delete the Signet record.
To maintain a “blame” history, we can instead record who and when the signet was revoked with a RevokedSignet.
Module Contents#
Classes#
Custom queries for signets |
|
Filters out revoked signets from queryset - should be the default manager |
|
Filters out un-revoked signets from queryset (only revoked signets returned |
|
Abstract base class for all Signet models A Signet is the model for a single “signature” or a user’s personal “seal” or “sigil” Persistence layer for a signoff: who, when, what (what is supplied by concrete class, e.g., with a FK to other model) Note: user relation is required for signing - enforced by app logic rather than at DB level so that… SET_NULL on_delete for user field is sensible for use-cases where signoff should persist even after user is deleted. For other on_delete behaviours, concrete RevokedSignet classes will need to override the user relation. |
|
Abstract base class for all Signet Revocation models A Revoked Signet is a record of a signet that was removed. Only needed if a record of revoked signets is required. Persistence layer for revoked signet: who, when, what (what is an app-relative concrete Signet model) Note: user relation is required for signing - enforced by app logic rather than at DB level - see AbstractSignet |
Functions#
Raise ValidationError if value is not a registered Signoff Type ID |
|
Return a dictionary of default values for fields the given signet - this is the default implementation for settings.SIGNOFFS_SIGNET_DEFAULTS setting. Called just before signet is saved - signet is guaranteed to have a valid user object. Dictionary keys must match signet model field names - only editable fields of signet may have defaults. Only fields with no value will be set to its default value. |
Data#
API#
- class signoffs.core.models.signets.SignetQuerySet(model=None, query=None, using=None, hints=None)[source]#
Bases:
django.db.models.QuerySetCustom queries for signets
Initialization
- signoffs.core.models.signets.BaseSignetManager#
None
- class signoffs.core.models.signets.ActiveSignetManager[source]#
Bases:
signoffs.core.models.signets.BaseSignetManagerFilters out revoked signets from queryset - should be the default manager
- class signoffs.core.models.signets.RevokedSignetManager[source]#
Bases:
signoffs.core.models.signets.BaseSignetManagerFilters out un-revoked signets from queryset (only revoked signets returned
- signoffs.core.models.signets.validate_signoff_id(value)[source]#
Raise ValidationError if value is not a registered Signoff Type ID
- signoffs.core.models.signets.get_signet_defaults(signet)[source]#
Return a dictionary of default values for fields the given signet - this is the default implementation for settings.SIGNOFFS_SIGNET_DEFAULTS setting. Called just before signet is saved - signet is guaranteed to have a valid user object. Dictionary keys must match signet model field names - only editable fields of signet may have defaults. Only fields with no value will be set to its default value.
- class signoffs.core.models.signets.AbstractSignet(*args, **kwargs)[source]#
Bases:
django.db.models.ModelAbstract base class for all Signet models A Signet is the model for a single “signature” or a user’s personal “seal” or “sigil” Persistence layer for a signoff: who, when, what (what is supplied by concrete class, e.g., with a FK to other model) Note: user relation is required for signing - enforced by app logic rather than at DB level so that… SET_NULL on_delete for user field is sensible for use-cases where signoff should persist even after user is deleted. For other on_delete behaviours, concrete RevokedSignet classes will need to override the user relation.
Initialization
- signoff_id#
None
- user#
None
- sigil#
None
- sigil_label#
None
- timestamp#
None
- objects#
None
- revoked_signets#
None
- all_signets#
None
- read_only_fields#
(‘signoff_id’, ‘timestamp’)
- property signoff_type#
Return the Signoff Type (class) that governs this signet
- signoff()#
The Signoff instance for this signet
- property signatory#
Return the user who signed, or AnonymousUser if signed but no signatory, None if not yet signed
- sign(user)[source]#
Sign unsigned signet for given user. If self.is_signed() raises PermissionDenied
- is_revoked()[source]#
Return True if this Signet has been revoked - Performance: .with_revoked_receipt() to avoid extra query
- can_save()[source]#
Return True iff this signet is data-complete and ready to be saved, but has not been saved before
- update(defaults=False, **attrs)[source]#
Update instance model fields with any attrs that match by name, optionally setting only unset fields
- get_signet_defaults()[source]#
Return dict of default field values for this signet - signet MUST have user relation!
- set_signet_defaults()[source]#
Set default field values for this signet - signet MUST have user relation!
- class signoffs.core.models.signets.AbstractRevokedSignet(*args, **kwargs)[source]#
Bases:
django.db.models.ModelAbstract base class for all Signet Revocation models A Revoked Signet is a record of a signet that was removed. Only needed if a record of revoked signets is required. Persistence layer for revoked signet: who, when, what (what is an app-relative concrete Signet model) Note: user relation is required for signing - enforced by app logic rather than at DB level - see AbstractSignet
Initialization
- signet#
None
- user#
None
- reason#
None
- timestamp#
None
signoffs.contrib.signets.models#
Basic concrete implementation for Signet models
Module Contents#
Classes#
A concrete persistence layer for basic Signoffs with no relations. |
|
A concrete persistence layer for revoked Signoffs. |