Athento allows you to create masks to modify the behaviour of the trays.
A mask is a Python language module that receives as parameters the elements to be displayed in the tray.
In the code of the Athento project, you can see a mask template in the path athentose/athentose/custom/queuemasks/hello_world.py whose content is:
def run(q, items, **kwargs):
for i in items:
i['helloworld'] = 'Hello World!'
doc = i.get('doc')
return items
Basically, a mask is a function that receives as first parameter the object of the tray and as second parameter the list of elements of the tray.
As a result, it must return a list of elements, which may have been modified.
The line:
doc = i.get('doc')
allows us to retrieve the document from a row of the tray, so that, from it, we can do any operation that can be done with a document.
For example, the following mask obtains for each document the value of a metadata and concatenates the symbol € and adds the new value as a new column called "total_in_euros".
def run(q, items, **kwargs):
for i in items:
doc = i.get('doc')
total_factura = doc.gmv('metadata.total_factura')
i['total_en_euros'] = total_factura + '€'
return items
Comments
0 comments
Please sign in to leave a comment.