Wednesday, March 4, 2015

Please specify a doctor type

When inserting a aids.RefundConfirmation: Lino now says Please specify a doctor type (“Bitte geben Sie die Art des Arztes an”) if user leaves both doctor and doctor_type blank (instead of raising an IntegrityError (1048, "Column 'doctor_type_id' cannot be null")).

‘Role’ object has no attribute ‘language’

If the recipient of an aid confirmation is a lino.modlib.contacts.models.Role, Lino no longer raises an AttributeError “‘Role’ object has no attribute ‘language’”

Combinations of two

I started to work on #118. The first part is a general problem: how to find duplicate persons in a database. This is done by lino.modlib.dedupe, but until now it was just a proof of concept which needed to be optimized. That’s done now. See Avoiding duplicate clients.

Side effects:

  • not only persons but all partners

  • uses a new database field phonetic_name

  • Use a model mixin and override full_clean.

This is an example case where Django’s signals would cause a lot of trouble and hacking while overriding a model mixin and full_clean is elegant.

The optimized algorithem uses combinations:

>>> from itertools import combinations
>>> [''.join(c) for c in combinations(['a', 'b'], 2)]
>>> [''.join(c) for c in combinations(['a', 'b', 'c'], 2)]
['ab', 'ac', 'bc']
>>> [''.join(c) for c in combinations(['a', 'b', 'c', 'd'], 2)]
['ab', 'ac', 'ad', 'bc', 'bd', 'cd']

Lino and Django 1.7

Mahmoud correctly discovered Daniel’s blog entry about how to get rid of the warning “1_6.W001”. Added a TEST_RUNNER setting to lino.projects.std.settings.