Thursday, February 19, 2015

I discovered a layout problem in the insert window of aids.IncomeConfirmationsByGranting: all form fields except remark are hidden.

The problem is a side effect of the new feature “hidden form fields” introduced some days ago (2015-02-17):

  • Fields specified as hidden_elements of an actor used to simply have no effect in any FormLayout. Now they have: they are included as hidden fields, so they can hold data, and submitting the form will transmit their data. The actual change is in LayoutHandle.create_element.

Testing screenshots

Before solving the problem itself I thought that this was the occasion to try WeasyPrint:

>>> url = '/api/pcsw/Clients/-99999?an=insert'
>>> res = test_client.get(url, REMOTE_USER='rolf')
>>> res.status_code
>>> html = res.content
>>> from weasyprint import HTML, CSS
>>> css = CSS(string='body { font-family: serif !important }')
>>> outfile = 'tmp.png'
>>> HTML(string=html).write_png(outfile, stylesheets=[css])

That would have been a cool thing for generating screenshots and testing them. But it was of course utopic: the <body> of a normal Lino html page is empty because it uses ExtJS. It works using a javascript <script> tag which defines an Ext.onReady handler:

<script type="text/javascript">
    Ext.onReady(function() {
    }); // end of onReady()"

No… this shows again that we need phantomjs if we want to generate screenshots. I once started this in makescreenshots, but as far as I remember there was a problem with getting them to play fair in a batch process.


I commented out the two lines of code to temporarily undo the new feature, then checked in and pulled in CPAS de Châtelet. Now they can create Clients again. The disadvantage is that they can’t edit the remark of a poll because this is where the new feature was needed.

A tough problem

The problem is a tough one… it deserves a tested document on its own: Inspecting a FormLayout and its JavaScript