Thursday, January 22, 2015

You are busy with … (#61)

Wow, Lino has two new features.

After meditating about how Lino Welfare should inform users that they “are busy with” a client. Yesterday I wrote that they want to be able to close such a meeting with a single click from their main page (plus another click on a confirmation naming all these guests). And they want it even if there’s more than one guest.

This is a new kind of welcome message. We don’t want to see a table of “all my active meetings” because that table would never show more than one row. So makes no sense here to bind the message handler (the callable which builds the message) to an existing Table.

Until now, welcome messages were defined by writing a method get_welcome_messages on some table. This method is still useful if your message is of style “you have x rows in foos” and clicking on it would open that table.

But now you can alternatively use the new method dd.add_welcome_handler to define welcome messages which are not bound to any Table.

Our first use case is which does exactly what we want for Lino Welfare.

There was another problem: The normal way to include into my welcome message, a button which invokes that action is something like:


But the CloseMeeting action is a workflow action (declared using lino.core.workflows.State.add_transition()), and thus it is not explicitly declared on the model using the usual method:

close_meeting = CloseMeeting()

So here is yet another (very subtle) feature: named workflow actions are now automatically declared on the model as a class attribute. So that I can now write above code.

Restore the Lino Welfare test suite

It’s time to have a look at the Lino Welfare test suite which had been neglected for some time after recent changes.

The shortcut fields are now defined in lino_welfare.projects.base by overriding setup_choicelists. That was necessary and is elegant, but it caused a subtle problem: lino_welfare.projects.chatelet wants these shortcut fields, too, but defines their own list of user profiles and cannot call super() for these because it has no lino_welfare.modlib.debts (and anyway it is not elegant to let the UserProfiles get filled just to reset them again afterwards). That’s why User profiles for Lino Welfare are no longer be defined in setup_choicelists but in the new Site method setup_user_profiles().

The test suite revealed one bug for which I am glad that I didn’t do a quick release this morning: Contract evaluation events got a duplicate Guest entry for their client.

I also continued on #60 (“Termine machen für Neuzugänge”, i.e. the AgentsByClient table), for which there is already a test case in The lino_welfare.modlib.reception plugin.

This ticket took so long because there was still a missing feature in the actions API.