20130817 (Saturday, 17 August 2013)

ForeignKey to cal.Event was not clickable for everybody

Fixed the following problem:

  • In Lino-Welfare, when Caroline has some event listed in welfare.cal.MyEvents, then she cannot click in the when_text column to see the detail of an event.

Did some code cleanup before deciding how to actually solve this:

  • Removed lino.core.dbutils.get_model_report. Existing code should call lino.core.model.get_default_table().

  • Replaced existing occurences of Model._lino_default_table by Model.get_default_table().

  • lino.ui.views.choices_for_field no longer looks for a magic class attribute _lino_choices_table.

The solution was then to write a new table OneEvent:

class OneEvent(Events):
    show_detail_navigator = False
    use_as_default_table = False
    required = dd.required(user_groups='office')

and to override lino.core.model.Model.get_default_table():

def get_default_table(cls):
    return OneEvent

Discovered and fixed another internal bug: calling unicode() on a cal.Calendar returned something like “Row #1” because Calendar is now a Sequenced. Changed the order of base classes from

class Calendar(BabelNamed,Sequenced,PrintableType,MailableType):


class Calendar(Sequenced,PrintableType,MailableType,BabelNamed):

Test suite cleanup

  • lino.projects.presto was broken:

    ~/hgwork/lino/lino/projects/presto$ python manage.py validate
    Exception: sales.InvoicingsByInvoiceable : no master for master_key u'invoiceable'
    in <class 'lino.modlib.sales.models.InvoiceItem'>

    This was because Presto still uses the obsolote way of manually specifying override_modlib_models. If you do that, then you must not forget any model. Added [‘sales.Invoice’, ‘sales.InvoiceItem’] (required by lino.modlib.auto.sales ) to the list. TODO: convert Presto to using overridden apps.

  • Fixed a failing test in lino.projects.events.

Customized when_text of welfare.cal.Event

Solved the following change request:

  1. In welfare.reception.AppontmentsByClient (Kolonne when_text): Text “2013 Aug 12 (Mo.)” ersetzen durch etwas Passenders (z.B. “heute”, “gestern”, “in 3 Tagen”).

By overriding the virtual field when_text in lino_welfare.modlib.cal.models.Event.

Also added django.contrib.humanize to lino_welfare.Site.get_installed_apps() in order to have translations available for this module.

To inherit or not?

Solved the following user request for Lino Welfare:

  • In Empfang ‣ Klienten <welfare.reception.Clients>: fehlt ein insert_layout.

reception.Clients and pcsw.Clients are on the same database model, and the spontaneous approach is to have reception.Clients inherit from pcsw.Clients:

class Clients(pcsw.Clients):

OTOH there are more things we don’t want to inherit than things we want. E.g. we don’t want the detail_layout, parameters, column_names, requirements,… So another possibility is to create a new Table from scratch, using the same model:

class Clients(dd.Table):
    model = 'pcsw.Clients'

The current solution is (again) the spontaneous one) because one thing we do want to inherit is the insert_layout, and manually inheriting a layout from a different datasource is not straightforward. We would have to write:

insert_layout = pcsw.Clients.insert_layout.main # manually inherited

So I decided to inherit the whole table and then override those things we don’t want to have here. Afterwards I understood that “removing” the parameter panel from the parent table is not really easy and decided to leave it there.

Moved lino.utils.auth to lino.core.auth

Because the lino.core.auth module is definitively part of lino.core.

WaitingGuests and MyWaitingGuests

Another user request:

  • Wartende Besucher: par défaut nur die meinen anzeigen

Added new method lino.ui.Site.get_admin_main_items() and generalized admin_main.html. lino_welfare.settings.Site.get_admin_main_items() now yields both WaitingGuests and MyWaitingGuests. The trick is that every normal user sees only one of them: Theresia (the reception clerk in our demo) sees all waiting guests while the agents (integ, debts, newcomers) see only their guests (Both of them can click on the title to show it in a window and select other parameters). That’s nice.

Less nice is that I have to either be very hackerish or to duplicate some code in order to get the welfare-specific behaviour of allowing only Clients as Guests. See the source code of lino_welfare.modlib.reception.models. TODO: find a beautiful solution…

And a last user request for this table was relatively easy:

  • Wartende Besucher: “Empfangen” vor “Auschecken”

This needed just a series of manual lino.core.actions.Action.sort_index values for these three actions.