system : some system features

The lino.modlib.system plugin defines some "system features", especially the SiteConfig model. It is automatically installed with every Lino application.

A tested document

This is a tested document. The following instructions are used for initialization:

Code snippets in this document are tested using the lino_book.projects.team demo project.

>>> import lino
>>> lino.startup('lino_book.projects.team.settings.doctests')
>>> from lino.api.doctest import *
class lino.modlib.system.Lockable

Mixin to add row-level edit locking to any model.

Models with row-level edit locking are not editable in detail view by default. All form fields are disabled. The user must click Edit in order to request an edit lock for that row. This will enable all fields (except those which are disabled for some other reason).

Caveats: locking a row and then navigating away without changing anything will leave the row locked.

class lino.modlib.system.BuildSiteCache

Rebuild the site cache. This action is available on About.

class lino.modlib.system.SiteConfigs

The table used to present the SiteConfig row in a Detail form.

See also lino.core.site.Site.get_site_config().

class lino.modlib.system.SiteConfig

A singleton database object used to store persistent site parameters.

This model has exactly one instance, which is accessible by application code as the settings.SITE.site_config property.

default_build_method

The default build method to use when rendering printable documents.

If this field is empty, Lino uses the value found in lino.core.site.Site.default_build_method.

simulate_today

A constant user-defined date to be substituted as current system date.

This should be empty except in situations such as a posteriori data entry in a prototype.

site_company

The organisation who runs this site. This is used e.g. when printing your address in certain documents or reports. Or newly created partners inherit the country of the site owner.

If no plugin named 'contacts' is intalled, then this is a dummy field which always contains None.

hide_events_before

If this is not empty, any calendar events before that date are being hidden in certain places.

For example OverdueEvents, EntriesByController, ...

Injected by lino_xl.lib.cal.

class lino.modlib.system.SiteConfigManager

Always return the cached instance which holds the one and only database instance.

This is to avoid the following situation:

  • User 1 opens the Configure ‣ System‣ System Parameters dialog

  • User 2 creates a new Person (which increases next_partner_id)

  • User 1 clicks on Save.

next_partner_id may not get overwritten by its old value when User 1 clicks "Save".

class lino.modlib.system.BleachChecker

A data checker used to find unbleached html content.

class lino.modlib.system.Genders

Defines the two possible choices "male" and "female" for the gender of a person.

See The Human mixin for examples. See Introduction to choicelists.

class lino.modlib.system.YesNo

A choicelist with two values "Yes" and "No".

Used e.g. to define parameter panel fields for BooleanFields:

foo = dd.YesNo.field(_("Foo"), blank=True)
class lino.modlib.system.ObservedEvent

Base class for choices of "observed event"-style choicelists.

add_filter(self, qs, pv)

Add a filter to the given Django queryset. The given obj must be either a datetime.date object or must have two attributes start_date and end_date. The easiest way is to have it an instance of DateRange or DateRangeValue.

class lino.modlib.system.PeriodEvents

The list of things you can observe on a lino.mixins.periods.DateRange.