Welcome | Get started | Dive | Contribute | Topics | Reference | Changes | More

lino.mixins

This package contains model mixins, some of which are heavily used by applications and the Lino Extensions Library. But none of them is mandatory.

duplicable

Defines the model mixin Duplicable.

dupable

Defines the Dupable model mixin and related functionality to assist users in finding unwanted duplicate database records.

sequenced

Defines the model mixins Sequenced and Hierarchical.

human

See test cases and examples in The Human mixin.

periods

Defines classes related to date ranges.

polymorphic

Defines the Polymorphic model mixin.

ref

Defines the Referrable model mixin.

registrable

This defines the Registable model mixin.

Classes

Contactable(*args, **kwargs)

Mixin for models that represent somebody who can be contacted by email.

Created(*args, **kwargs)

Adds a timestamp field which holds the creation time of every individual database object.

CreatedModified(*args, **kwargs)

Adds two timestamp fields created and modified.

DragAndDrop([label])

Draggable(*args, **kwargs)

Modified(*args, **kwargs)

Adds a a timestamp field which holds the last modification time of every individual database object.

Phonable(*args, **kwargs)

Mixin for models that represent somebody who can be contacted by phone.

ProjectRelated(*args, **kwargs)

Mixin for models that are related to a "project", i.e. to an object of the type given by your lino.core.site.Site.project_model.

Story(*args, **kwargs)

class lino.mixins.Contactable(*args, **kwargs)

Bases: Model

Mixin for models that represent somebody who can be contacted by email.

get_as_user()

Return the user object representing this contactable.

class lino.mixins.Phonable(*args, **kwargs)

Bases: Model

Mixin for models that represent somebody who can be contacted by phone.

class lino.mixins.Modified(*args, **kwargs)

Bases: Model

Adds a a timestamp field which holds the last modification time of every individual database object.

modified

The time when this database object was last modified.

auto_touch = True

Whether to touch objects automatically when saving them.

If you set this to False, modified is updated only when you explicitly call touch().

class lino.mixins.Created(*args, **kwargs)

Bases: Model

Adds a timestamp field which holds the creation time of every individual database object.

created

The time when this object was created.

Does nut use Django’s auto_now and auto_now_add features because their deserialization would be problematic.

class lino.mixins.CreatedModified(*args, **kwargs)

Bases: Created, Modified

Adds two timestamp fields created and modified.

class lino.mixins.ProjectRelated(*args, **kwargs)

Bases: Model

Mixin for models that are related to a “project”, i.e. to an object of the type given by your lino.core.site.Site.project_model.

This adds a field named project and related methods.

project

Pointer to the project to which this object is related.

If the application’s project_model is empty, the project field will be a DummyField.

update_owned_instance(controllable)

When a project-related object controls another project-related object, then the controlled automatically inherits the project of its controller.