Skip to content

angee.base.mixins

Reusable abstract model mixins for Angee source models.

actor_user_id

python
def actor_user_id(actor: Any) -> Any | None

Return actor's user subject id, or None when it is not a user.

The one reading of "this REBAC actor, as a user id" — the value that backs user-owned columns (created_by / updated_by / trashed_by …).

ModelDecorator

python
@dataclass(frozen=True, slots=True)
class ModelDecorator()

Decorator the composer applies to emitted concrete models.

TimestampMixin

python
class TimestampMixin(models.Model)

Add conventional creation and update timestamps to a model.

created_at

The timestamp when the row was first created.

updated_at

The timestamp when the row was most recently saved.

Meta

python
class Meta()

Django model options for timestamp-only abstract inheritance.

SqidMixin

python
class SqidMixin(models.Model)

Add an opaque public identifier backed by the model primary key.

A model sets only the varying fact — its prefix — as sqid_prefix (e.g. sqid_prefix = "nte_"); the shared sqid column reads it (see SqidField.contribute_to_class), so no model re-declares the field.

sqid_prefix

Public-id prefix for sqid (e.g. "nte_"); empty means no prefix.

sqid

Opaque public identifier encoded from the integer primary key.

Meta

python
class Meta()

Django model options for sqid-only abstract inheritance.

public_id_value

python
def public_id_value() -> Any

Return the raw public identifier value for this instance.

public_id_lookup

python
@classmethod
def public_id_lookup(cls, value: str) -> dict[str, Any]

Return the Django lookup for this model's public identifier.

public_id_from_pk

python
@classmethod
def public_id_from_pk(cls, value: Any) -> str

Return the public id encoded from this model's primary-key value.

AuditMixin

python
class AuditMixin(models.Model)

Add conventional user-owned audit foreign keys to a model.

created_by

The user that created the row, when known.

updated_by

The user that most recently updated the row, when known.

Meta

python
class Meta()

Django model options for audit-only abstract inheritance.

save

python
def save(*args: Any, **kwargs: Any) -> None

Persist the row after stamping user audit fields.

HistoryMixin

python
class HistoryMixin(models.Model)

Mark a model as tracked by django-simple-history.

Meta

python
class Meta()

Django model options for history-only abstract inheritance.

RevisionMixin

python
class RevisionMixin(models.Model)

Mark a model as tracked by django-reversion snapshots.

angee_model_decorators

Composer decorators applied to emitted concrete revision models.

revisioned_fields

Model field names registered with django-reversion.

Meta

python
class Meta()

Django model options for revision-only abstract inheritance.

revisions

python
@property
def revisions() -> Any

Return this row's django-reversion versions newest-first.

revert_to

python
def revert_to(version: Any) -> None

Restore declared revisioned fields from version and save.

Saves with update_fields so unrelated in-memory columns are not flushed, but includes the model's auto_now timestamps so a revert advances updated_at consistently with the audit updated_by stamp (Django only refreshes auto_now fields named in update_fields).

Released under the AGPL-3.0 License.