signoffs.core.models.stamps#

A “Stamp of Approval” is the persistence layer that backs an Approval - the timestamp that seals the Approval. - often models the set of related Signets that define the Approval’s “Signing Order”. A concrete Stamp may have other information about, or perhaps a relation to, the thing being approved.

A Stamp records status of an Approval, and is often automated by business logic defining when the Approval is complete. An approved Stamp record provides evidence that a particular Approval was granted and by whom (via signatories). A Stamp may be granted directly if business rules dictate, but normally is granted via one or more Signets. Otherwise, a Stamp is not ordinarily edited directly - add and revoke Signets to move it through its signing order. Once granted, the Stamp persists its “approved” status, regardless of the state of underlying Signets or changes to the Approval process. To revoke a Stamp, we alter the approval status and revoke the Signet(s) used to grant the Approval. A “blame” history, may be maintained by using a RevokeSignet model on the Approval Type.

Module Contents#

Classes#

AbstractApprovalSignet

A Signet representing one signature on an Approval. The Approval Stamp related_name must be “signatories”

ApprovalStampQuerySet

Custom queries for Approval Seal

AbstractApprovalStamp

Abstract base class for all “Stamp of Approval” models A Stamp is the model often on the One side of a Many-To-One relation from an ApprovalSignet Persistence layer that timestamps an approval: who, when, what (what is supplied by concrete class, e.g., with a FK to other model)

Functions#

validate_approval_id

Raise ValidationError if value is not a registered Approval Type ID

Data#

API#

class signoffs.core.models.stamps.AbstractApprovalSignet(*args, **kwargs)[source]#

Bases: signoffs.core.models.signets.AbstractSignet

A Signet representing one signature on an Approval. The Approval Stamp related_name must be “signatories”

Initialization

stamp#

None

class Meta[source]#

Bases: signoffs.core.models.signets.AbstractSignet.Meta

abstract#

True

class signoffs.core.models.stamps.ApprovalStampQuerySet(model=None, query=None, using=None, hints=None)[source]#

Bases: django.db.models.QuerySet

Custom queries for Approval Seal

Initialization

approved()[source]#

Filter out unapproved stamps

incomplete()[source]#

Return only stamps that are not yet approved

prefetch_signets()[source]#

Prefetch related signets but not the signing users

prefetch_signatories()[source]#

Prefetch related signets and their signing users

approvals(approval_id=None, subject=None)[source]#

Returns list of approval objects, one for each seal in queryset, optionally filtered for specific approval type - filtering done in-memory for performance.

signoffs.core.models.stamps.ApprovalStampManager#

None

signoffs.core.models.stamps.validate_approval_id(value)[source]#

Raise ValidationError if value is not a registered Approval Type ID

class signoffs.core.models.stamps.AbstractApprovalStamp(*args, **kwargs)[source]#

Bases: django.db.models.Model

Abstract base class for all “Stamp of Approval” models A Stamp is the model often on the One side of a Many-To-One relation from an ApprovalSignet Persistence layer that timestamps an approval: who, when, what (what is supplied by concrete class, e.g., with a FK to other model)

Initialization

approval_id#

None

approved#

None

timestamp#

None

class Meta[source]#
abstract#

True

ordering#

[‘timestamp’]

objects#

None

read_only_fields#

(‘approval_id’, ‘timestamp’)

__str__()[source]#
property approval_type#

Return the Approval Type (class) that governs this stamp

get_approval(subject=None)[source]#

Return an Approval instance for this stamp

property approval#

The Approval instance for this stamp

is_approved()[source]#

return True if this Stamp is approved and has a persistent representation in DB

approve()[source]#

Approve the stamp (but don’t commit the change) No permissions involved here - just force this stamp into approved state!

is_user_signatory(user)[source]#

return True iff the given user is a signatory on this stamp

has_valid_approval()[source]#

return True iff this Stamp has a valid approval_id

save(*args, **kwargs)[source]#

Validate and save this stamp

classmethod has_object_relation()[source]#

Return True iff this Stamp class has a FK relation to some object other than user

signoffs.contrib.approvals.models#

Basic concrete implementations for ApprovalStamp related models

Module Contents#

Classes#

Signet

A concrete persistence layer for a basic Signet with a relation to an ApprovalStamp

RevokedSignet

A concrete persistence layer for tracking revoked Approval Signets. May be declared on Approval Types to provide persistence / tracking of revoked signoffs.

Stamp

A concrete persistence layer for basic Approval Types

API#

class signoffs.contrib.approvals.models.Signet(*args, **kwargs)[source]#

Bases: signoffs.core.models.AbstractApprovalSignet

A concrete persistence layer for a basic Signet with a relation to an ApprovalStamp

Initialization

class signoffs.contrib.approvals.models.RevokedSignet(*args, **kwargs)[source]#

Bases: signoffs.core.models.AbstractRevokedSignet

A concrete persistence layer for tracking revoked Approval Signets. May be declared on Approval Types to provide persistence / tracking of revoked signoffs.

Initialization

class signoffs.contrib.approvals.models.Stamp(*args, **kwargs)[source]#

Bases: signoffs.core.models.AbstractApprovalStamp

A concrete persistence layer for basic Approval Types

Initialization