Printing

A tested document

This is a tested document. The following instructions are used for initialization:

>>> import lino
>>> lino.startup('lino_prima.projects.prima1.settings')
>>> from lino.api.doctest import *

We take an object, clear the cache, ask Lino to print it and check whether we get the expected response.

>>> ses = rt.login("robin")
>>> def printit(obj):
...     obj.clear_cache()
...     d = ses.run(obj.do_print)
...     assert d['success']
...     print(d['message'])
...
>>> printit(projects.Project.objects.last())
... 
weasy2pdf render ['projects/Project/default.weasy.html'] ->
.../media/cache/weasy2pdf/Project-Aasiya
Crispeel-Leb-80.pdf ('en', {})
Your printable document (<a href="/media/cache/weasy2pdf/Project-Aasiya
Crispeel-Leb-80.pdf">Project-Aasiya Crispeel-Leb-80.pdf</a>) should now open in
a new browser window. If it doesn't, please ask your system administrator.
>>> qs = cert.Certificate.objects.all()
>>> printit(qs.last())  
weasy2pdf render ['cert/Certificate/default.weasy.html'] ->
.../media/cache/weasy2pdf/Certificate-Aatifa
Crispel-2-672.pdf ('en', {}) Your printable document (<a
href="/media/cache/weasy2pdf/Certificate-Aatifa
Crispel-2-672.pdf">Certificate-Aatifa Crispel-2-672.pdf</a>) should now open in
a new browser window. If it doesn't, please ask your system administrator.

The following failed on 20250728 with jinja2.exceptions.UndefinedError: ‘None’ has no attribute ‘rating_type’:

>>> qs = cert.Certificate.objects.filter(enrolment__group__designation="2A")
>>> qs = qs.filter(period__ref="2024/25-2")
>>> printit(qs.last()) 
weasy2pdf render ['cert/Certificate/default.weasy.html'] ->
.../media/cache/weasy2pdf/Certificate-Alma
André-2-94.pdf ('en', {})
Your printable document (<a href="/media/cache/weasy2pdf/Certificate-Alma
André-2-94.pdf">Certificate-Alma André-2-94.pdf</a>) should now open in a new
browser window. If it doesn't, please ask your system administrator.