Thursday, June 20, 2019

I worked on #3086 (together with Hamza at the beginning). Some optimizations for managing absences and holidays of workers.

Changes needed for Lino Presto.

If a presence_guest is specified this filter no longer applies to entries whose type has all_rooms enabled (which is the case e.g. for holidays).

Multi-day events must be shown on every day of their date range. Lino didn’t yet handle them correctly

I added a field lino_xl.lib.cal.EventType.fill_presences because not all events should automatically fill their presences (lino_xl.lib.cal.Guest). When lino_xl.lib.cal.EntryStates.edit_guests is True, Lino also removes unwanted guests each time you hit the save button. But for example in Lino Presto when registering a absence day or a worker, the list of suggested guests is usually empty (because the project is empty), and we don’t want Lino to remove any manually added guests.

The std fixture for lino_xl.lib.cal now adds a new entry type “Absence” with this configuration. The demo2 fixture adds some “absences for private reasons”, some of them several days.

En passant this caused an avalanche of optimizations.

I reviewed the way how the filter parameters for calendar entries (lino_xl.lib.cal.Event) are being inherited by the calendar views. Especially this was a bit too hackerish for me:

@classmethod
def setup_parameters(cls, fields):
    cls.params_layout = rt.models.cal.Event.params_layout
    cls.parameters = rt.models.cal.Event.parameters
super(Events, cls).setup_parameters(rt.models.cal.Event.parameters)

There is a danger that this caused bugs which are not covered by the test suite.

In the filter parameters of lino_xl.lib.cal.Events, I renamed partner to presence_guest and moved some help texts to the specs page.