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.

>>> from lino.api import startup
>>> startup('lino_book.projects.min9.settings')
>>> from lino.api.doctest import *

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.

lino.modlib.humans.days_coming

How many days into the future to show in “Upcoming birthdays”.

lino.modlib.humans.days_recent

How many days back to show in “Recent 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.

honorific_title

An optional professional position or academic qualification or nobility title like “Dr.” or “PhD” or “Baron”.

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_name and last_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

An IncompleteDateField.

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.timedelta object.

Optional keyword argument today should be a datetime.date instance 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. More precisely, “soon” means “in 3 days”, where the 3 comes from days_coming. “cecently” means “in the last 3 days”, where the 3 comes from days_recent.

>>> ar = rt.login("robin")
>>> def run_test():
...     for today in (20230619, 20231230, 20231229, 20240101):
...         today = i2d(today)
...         print(dd.fdf(today))
...         soup = beautiful_soup("\n".join(humans.show_birthdays(ar, today)))
...         for ln in soup.text.splitlines():
...             print("-", ln)
>>> run_test()
Monday, 19 June 2023
- Birthdays today: Paul Frisch (56), Peter Frisch (36), Clara Frisch (24)
Saturday, 30 December 2023
- Birthdays today: Johann Johnen (59)
- Recent birthdays: Dec 12 Jérôme Jeanémart (59), Dec 12 Dora Drosson (52)
- Upcoming birthdays: Jan 1 Josef Jonas (58), Jan 1 Philippe Frisch (26), Dec 12 Petra Zweith (55)
Friday, 29 December 2023
- Birthdays today: Dora Drosson (52)
- Recent birthdays: Dec 12 Jérémy Jansen (59), Dec 12 Jérôme Jeanémart (59)
- Upcoming birthdays: Jan 1 Josef Jonas (58), Jan 1 Philippe Frisch (26), Dec 12 Johann Johnen (59), Dec 12 Petra Zweith (55)
Monday, 1 January 2024
- Birthdays today: Josef Jonas (59), Philippe Frisch (27)
- Recent birthdays: Dec 12 Dora Drosson (53), Dec 12 Johann Johnen (60), Dec 12 Petra Zweith (56)
- Upcoming birthdays: Jan 1 Jan Jousten (59), Jan 1 Dennis Frisch (23)
>>> with translation.override('fr'):
...     run_test()
lundi 19 juin 2023
- Anniversaires aujourd'hui: Paul Frisch (56), Peter Frisch (36), Clara Frisch (24)
samedi 30 décembre 2023
- Anniversaires aujourd'hui: Johann Johnen (59)
- Anniversaires récents: 12 Déc Jérôme Jeanémart (59), 12 Déc Dora Drosson (52)
- Anniversaires à venir: 1 Jan Josef Jonas (58), 1 Jan Philippe Frisch (26), 12 Déc Petra Zweith (55)
vendredi 29 décembre 2023
- Anniversaires aujourd'hui: Dora Drosson (52)
- Anniversaires récents: 12 Déc Jérémy Jansen (59), 12 Déc Jérôme Jeanémart (59)
- Anniversaires à venir: 1 Jan Josef Jonas (58), 1 Jan Philippe Frisch (26), 12 Déc Johann Johnen (59), 12 Déc Petra Zweith (55)
lundi 1 janvier 2024
- Anniversaires aujourd'hui: Josef Jonas (59), Philippe Frisch (27)
- Anniversaires récents: 12 Déc Dora Drosson (53), 12 Déc Johann Johnen (60), 12 Déc Petra Zweith (56)
- Anniversaires à venir: 1 Jan Jan Jousten (59), 1 Jan Dennis Frisch (23)
>>> with translation.override('de'):
...     run_test()
Montag, 19. Juni 2023
- Geburtstage heute: Paul Frisch (56), Peter Frisch (36), Clara Frisch (24)
Samstag, 30. Dezember 2023
- Geburtstage heute: Johann Johnen (59)
- Geburtstage vor Kurzem: 12. Dez Jérôme Jeanémart (59), 12. Dez Dora Drosson (52)
- Kommende Geburtstage: 1. Jan Josef Jonas (58), 1. Jan Philippe Frisch (26), 12. Dez Petra Zweith (55)
Freitag, 29. Dezember 2023
- Geburtstage heute: Dora Drosson (52)
- Geburtstage vor Kurzem: 12. Dez Jérémy Jansen (59), 12. Dez Jérôme Jeanémart (59)
- Kommende Geburtstage: 1. Jan Josef Jonas (58), 1. Jan Philippe Frisch (26), 12. Dez Johann Johnen (59), 12. Dez Petra Zweith (55)
Montag, 1. Januar 2024
- Geburtstage heute: Josef Jonas (59), Philippe Frisch (27)
- Geburtstage vor Kurzem: 12. Dez Dora Drosson (53), 12. Dez Johann Johnen (60), 12. Dez Petra Zweith (56)
- Kommende Geburtstage: 1. Jan Jan Jousten (59), 1. Jan Dennis Frisch (23)