angee.base.mixins
Reusable abstract model mixins for Angee source models.
actor_user_id
def actor_user_id(actor: Any) -> Any | NoneReturn 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
@dataclass(frozen=True, slots=True)
class ModelDecorator()Decorator the composer applies to emitted concrete models.
TimestampMixin
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
class Meta()Django model options for timestamp-only abstract inheritance.
SqidMixin
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
class Meta()Django model options for sqid-only abstract inheritance.
public_id_value
def public_id_value() -> AnyReturn the raw public identifier value for this instance.
public_id_lookup
@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
@classmethod
def public_id_from_pk(cls, value: Any) -> strReturn the public id encoded from this model's primary-key value.
AuditMixin
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
class Meta()Django model options for audit-only abstract inheritance.
save
def save(*args: Any, **kwargs: Any) -> NonePersist the row after stamping user audit fields.
HistoryMixin
class HistoryMixin(models.Model)Mark a model as tracked by django-simple-history.
Meta
class Meta()Django model options for history-only abstract inheritance.
RevisionMixin
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
class Meta()Django model options for revision-only abstract inheritance.
revisions
@property
def revisions() -> AnyReturn this row's django-reversion versions newest-first.
revert_to
def revert_to(version: Any) -> NoneRestore 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).