def render_printouts_pdf(view_name, meeting_id, printout_type): app = flask.current_app flask.g.pdf_compatible = True kwargs = {} view = app.view_functions.get('printouts.%s' % view_name) temp = path(app.config['PRINTOUTS_PATH']) if not temp.exists(): temp.makedirs() template = view.not_protected.not_templated.template_name kwargs['context'] = view.not_protected.not_templated(meeting_id, printout_type) kwargs['temp'] = temp kwargs['width'] = '11.7in' kwargs['height'] = '8.3in' kwargs['is_celery_processs'] = True return sugar.render_pdf(template, **kwargs)
def render_participant_pdf(template, **kwargs): from cites.participant import _get_persons_in_categories meta = kwargs.pop('meta') meeting = models.Meeting.select().where(id=meta['meeting_id']).get() persons, count = _get_persons_in_categories(meta['meeting_id'], meta['categories'], meta['person_type'], limited=False) for person in persons: if 'photo' in person.data and person.data['photo']: person.photo_url = meta['photos'].joinpath(person.data['photo']) else: person.photo_url = None kwargs['context']['persons'] = persons kwargs['context']['meeting'] = meeting kwargs['is_celery_processs'] = True kwargs['use_wkhtmltopdf'] = True return sugar.render_pdf(template, **kwargs)