def _process(self): ids = request.args.getlist('a') results = {int(id_): cache.get(id_) for id_ in ids} finished = [id_ for id_, status in results.iteritems() if status == 'finished'] pending = [id_ for id_, status in results.iteritems() if status == 'pending'] containers = {} if finished: tpl = get_template_module('attachments/_display.html') for attachment in Attachment.find(Attachment.id.in_(finished)): if not attachment.folder.can_view(session.user): continue containers[attachment.id] = tpl.render_attachments_folders(item=attachment.folder.object) return jsonify(finished=finished, pending=pending, containers=containers)
def _event_display_after_attachment(self, attachment, top_level, has_label, **kwargs): if attachment.type != AttachmentType.file: return None if now_utc() - attachment.file.created_dt > info_ttl: return None if cache.get(unicode(attachment.id)) != 'pending': return None return render_plugin_template('pdf_attachment.html', attachment=attachment, top_level=top_level, has_label=has_label, title=get_pdf_title(attachment))