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.

uploadable

Defines the Uploadable mixin.

ref

Defines the Referrable model mixin.

registrable

This defines the Registable model mixin.

(This module's source code is available here.)

Classes

Contactable(*args, **kwargs)

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

Created(*args, **kwargs)

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

CreatedModified(*args, **kwargs)

Adds two timestamp fields created and modified.

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".

Story(*args, **kwargs)

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

Bases: lino.core.model.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: lino.core.model.Model

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

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

Bases: lino.core.model.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: lino.core.model.Model

Adds a 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: lino.mixins.Created, lino.mixins.Modified

Adds two timestamp fields created and modified.

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

Bases: lino.core.model.Model

Mixin for models that are related to a "project". This adds a field named project and related default behaviour.

A project in this context means what the users consider "the central most important model that is used to classify most other things". For example in Lino Avanti the "project" is a Client while in Lino Tera it is a therapy. The application's project model is specified in lino.core.site.Site.project_model.

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.