excerpts: Database excerpts¶
lino_xl.lib.excerpts plugin adds the notion of database excerpts.
We assume that you have read excerpts : Print using database excerpts and printing : Basic printing functionality.
This is a tested document. The following instructions are used for initialization:
>>> from lino import startup >>> startup('lino_book.projects.min9.settings') >>> from lino.api.shell import * >>> from lino.api.doctest import *
Add the virtual field printed to your layout
Lino does not automatically add an action per model to make the excerpt history visible from a model. If you want this, add yourself your preferred variant.
This can be either using a
ShowSlaveTable button in the toolbar:
show_excerpts = dd.ShowSlaveTable('excerpts.ExcerptsByOwner') show_excerpts = dd.ShowSlaveTable('excerpts.ExcerptsByProject')
Or by adding
excerpts.ExcerptsByProject (or both, or
your own subclass of one of them) to the
In addition to the main template, excerpt types can specify a body template.
- body template¶
When the main template is being rendered, it has a context variable
which is itself rendered from a template.
As a site manager (and when
lino.modlib.davlink is installed) you
can easily modify the main template that has been used to print a given excerpt
Edit Template button in
the detail window of that
If you want to configure which document to use as main template, then you must use the Configuration menu:
- class lino_xl.lib.excerpts.Excerpt¶
A printable document that describes some aspect of the current situation.
The type of this excerpt (ForeignKey to
The object being printed by this excerpt. See
The optional contact person of the
recipientof this excerpt. See
The recipient of this excerpt. See
The language used for printing this excerpt.
- class lino_xl.lib.excerpts.ExcerptDetail¶
- class lino_xl.lib.excerpts.AllExcerpts¶
- class lino_xl.lib.excerpts.MyExcerpts¶
- class lino_xl.lib.excerpts.ExcerptsByType¶
- class lino_xl.lib.excerpts.ExcerptsByProject¶
Only used if
- class lino_xl.lib.excerpts.ExcerptType¶
The type of an excerpt. Every excerpt has a mandatory field
Excerpt.excerpt_typewhich points to an
The designation of this excerpt type. One field for every
The database model for which this excerpt type is to be used.
The main template to be used when printing an excerpt of this type.
The body template to use when printing an excerpt of this type.
The template to use when sending this an excerpt of this type by email.
- class lino_xl.lib.excerpts.ExcerptTypes¶
Displays all rows of
- class lino_xl.lib.excerpts.Certifiable¶
Any model which inherits from this mixin becomes "certifiable".
it has a
printed_byfield and a corresponding virtual field
printedwhich point to the excerpt that is the "definitive" ("Certifying") printout of this object.
It may define a list of "certifiable" fields by providing a
from lino_xl.lib.excerpts.mixins import Certifiable class MyModel(dd.UserAuthored, Certifiable, dd.Duplicable): ...
lino_xl.lib.excerpts.fixtures.stdfixture automatically creates a certifying
ExcerptTypeinstance for every model which inherits from
Displays information about when this certifiable has been printed. Clicking on it will display the excerpt pointed to by
ForeignKey to the
Excerptwhich certifies this instance.
Certifiableis considered "certified" when this this is not None.
Note that this field is a nullable ForeignKey with on_delete set to
- on_duplicate(self, ar, master)¶
After duplicating e.g. a budget which had been printed, we don't want the duplicate point to the same excerpt.
A class method. Expected to return a string with a space-separated list of field names. These files will automaticaly become disabled (readonly) when the document is "certified". The default implementation returns an empty string, which means that no field will become disabled when the row is "certified".
@classmethod def get_certifiable_fields(cls): return 'date user title'
- def get_excerpt_title(self)
A string to be used in templates as the title of the certifying document.
- get_excerpt_templates(self, bm)¶
Return either None or a list of template names to be used when printing an excerpt controlled by this object.
- class lino_xl.lib.excerpts.ExcerptTitle¶
Mixin for models like
The designation of this row as seen by the user e.g. when selecting an instance of this model.
One field for every
- excerpt shortcut field¶
A virtual display field with actions for quickly managing, for a given database object, its excerpt of a given type.
- class lino_xl.lib.excerpts.Shortcut¶
- class lino_xl.lib.excerpts.Shortcuts¶
A choicelists of excerpt shortcut fields.
These virtual fields are being installed during pre_analyze by
This template is the default value, used by many excerpt types in
template field. It is designed
to be locally overridden by local site managers in order to
match their letter paper.
- class lino_xl.lib.excerpts.BodyTemplateContentField¶
- class lino_xl.lib.excerpts.CreateExcerpt¶
Create an excerpt in order to print this data record.
- class lino_xl.lib.excerpts.ClearPrinted¶
Clear any previously generated printable document. Mark this object as not printed. A subsequent call to print will generate a new cache file.
A receiver for the
Installs (1) print management actions on models for which there is an excerpt type and (2) the excerpt shortcut fields defined in
Note that excerpt types for a model with has MTI children, the action will be installed on children as well. For example a
lino_book.projects.adgcan get printed either as a
TermsConditions.odtor as a
When the database does not yet exist (e.g. during
pm prep), it simply ignores that situation silently and does not define the print actions.
This is called for every new Excerpt object and it sets certain default values.
For the default language, note that the
recipient. This rule is important e.g. for printing aid confirmations in Lino Welfare.