Welcome | Get started | Dive | Contribute | Topics | Reference | Changes | More

Printing tables

This document just tests the print to pdf function.

All code snippets on this page (lines starting with >>>) are being tested as part of our development workflow. The following snippet initializes a demo project to use throughout this page.

>>> from lino_book.projects.noi1e.startup import *
>>> # rt.login('robin').show('tickets.ActiveTickets')
>>> settings.SITE.appy_params.update(raiseOnError=True)
>>> test_client.force_login(rt.login('robin').user)
>>> def mytest(k):
...     url = 'http://127.0.0.1:8000/api/{0}?an=as_pdf'.format(k)
...     res = test_client.get(url, REMOTE_USER='robin')
...     assert res.status_code == 200, "Request to {} got status code {}".format(url, res.status_code)
...     result = json.loads(res.content)
...     assert result['success']
...     print(result['open_url'])
>>> mytest("tickets/ActiveTickets")
/media/cache/appypdf/127.0.0.1/tickets.ActiveTickets.pdf
>>> mytest("tickets/AllTickets")
/media/cache/appypdf/127.0.0.1/tickets.AllTickets.pdf