Welcome | Get started | Dive | Contribute | Topics | Reference | Changes | More
humans : Managing humans¶
The lino.modlib.humans plugin adds functionality for managing humans.
We assume you have read the The humans plugin page of the User Guide.
This page contains code snippets (lines starting with >>>), which are
being tested during our development workflow. The following
snippet initializes the demo project used throughout this page.
>>> import lino
>>> lino.startup('lino_book.projects.min9.settings')
>>> from django.utils import translation
>>> from lino.api.doctest import *
>>> from django.db.models import Q
Configuration options¶
- lino.modlib.humans.show_birthdays¶
Whether to show upcoming and recent birthdays as a welcome message in the dashboard.
The default value is True unless the application developer changed it.
See examples in Showing birthdays.
Model mixins¶
- class lino.modlib.humans.Human¶
Base class for models that represent a human.
See The Human mixin for some examples. See also The Human mixin.
- title¶
An optional professional position or academic qualification like “Dr.” or “PhD”.
If given, the content of this field comes between salutation and name.
- first_name¶
The first name, also known as given name.
- last_name¶
The last name, also known as family name.
- middle_name¶
A space-separated list of all middle names.
- gender¶
The sex of this person (male, female, nonbinary).
Possible values are defined in
lino.modlib.system.Genders.
- mf()¶
Taking three parameters m, f and u of any type, returns one of them depending on whether this Person is male, female or of unknown gender.
- get_last_name_prefix()¶
May be used for handling special of titles (e.g. “Cardinal”, “Graf”) which come before the last name (not before the first name).
Lino currently does not support titles which replace the salutation (“Br.”, “Sr.”) or which must come at another position of the full name
External links: linguee.de and wikipedia.org
- get_full_name(self, salutation=True, upper=None, last_name_first=None, **salutation_options)¶
Returns a one-line string composed of salutation,
first_nameandlast_name.The optional keyword argument salutation can be set to False to suppress salutations.
The optional keyword argument upper can be specified to override the Site’s default value (
lino.core.site.Site.uppercase_last_name). True means to convert the last name to uppercase as is usually done in French.Any other keyword arguments are forwarded to
lino.modlib.humans.utils.get_salutation()(see there).If
get_after_salutation_words()yields a sequence of words, then these are inserted between salutation and first name.See The Human mixin for some examples.
- class lino.modlib.humans.Born¶
Abstract base class that adds a birth_date field and a virtual field “Age”. See also The Born mixin.
- birth_date¶
- age¶
Virtual field displaying the age in years.
- get_age(self, today=None)¶
Return the age (in years) of this human. See
lino.utils.IncompleteDate.get_age().
- get_exact_age(self, today=None)¶
Return the age as a
datetime.timedeltaobject.Optional keyword argument today should be a
datetime.dateinstance to replace the actual current date. This is used if you want the age at a given date in the past or the future.The default value calls
dd.Site.today().
Showing birthdays¶
When show_birthdays is True, Lino shows the name of persons who have
their birthday today, or will have it soon or had it recently.
>>> ar = rt.login("robin")
>>> print("\n".join(humans.show_birthdays(ar, i2d(20230619))))
<p><b>Birthdays today</b>: <a href="…">Paul Frisch</a> (56), <a href="…">Peter Frisch</a> (36), <a href="…">Clara Frisch</a> (24)</p>
>>> print("\n".join(humans.show_birthdays(ar, i2d(20231230))))
<p>Recent birthdays: 12-29 <a href="…">Dora Drosson</a> (52)</p>
<p>Upcoming birthdays: 01-01 <a href="…">Philippe Frisch</a> (26), 12-31 <a href="…">Petra Zweith</a> (55)</p>
>>> print("\n".join(humans.show_birthdays(ar, i2d(20231229))))
<p><b>Birthdays today</b>: <a href="…">Dora Drosson</a> (52)</p>
<p>Upcoming birthdays: 01-01 <a href="…">Philippe Frisch</a> (26), 12-31 <a href="…">Petra Zweith</a> (55)</p>
>>> print("\n".join(humans.show_birthdays(ar, i2d(20240101))))
<p><b>Birthdays today</b>: <a href="…">Philippe Frisch</a> (27)</p>
<p>Recent birthdays: 12-29 <a href="…">Dora Drosson</a> (53), 12-31 <a href="…">Petra Zweith</a> (56)</p>
<p>Upcoming birthdays: 01-03 <a href="…">Dennis Frisch</a> (23)</p>