def __call__(self): form = self.request.form if "form_submitted" in form: # The user clicked on the 'send by mail' # button. self.check_form() if not self.errors: self.process_form() msg = _(u"msg_success", default=u"The e-mail has been sent") msg_type = "info" else: msg = _(u"msg_error", default=u"Errors appeared while processing your form") msg_type = "error" self.context.plone_utils.addPortalMessage(translate(msg, target_language=self.get_lang()), type=msg_type) if not self.errors: self.request.response.redirect(self.context.absolute_url()) elif "form_cancelled" in form: # The user clicked on the 'cancel' button. self.request.response.redirect(self.context.absolute_url()) else: # The user clicked on the 'send by mail' # link. self.make_pdf() if self.errors: # The PDF generation did not work, we render the page # used when errors are found when sending the mail. self.index = ZopeTwoPageTemplateFile("templates/download.pt") # We need the self parameter for Plone 4 return self.index(self)
def _generatorVocabulary(self): return atapi.DisplayList([ ('pisa', _(u'label_pisa', default=u'XHTML2PDF: HTML/CSS to PDF converter written ' 'in Python (http://www.xhtml2pdf.com/)')), ('wk', _(u'label_wk', default=u'wkhtmltopdf: Simple shell utility to convert ' 'html to pdf using the webkit (Safari, Chrome) rendering ' 'engine (http://code.google.com/p/wkhtmltopdf/)'))])
def make_options(self): """ Returns a dictionnary of options that can be used in the tool. """ if self.pdf_generator == 'pisa': return {} toc_msg = _(u'label_toc', default=u'Table of content') options = { 'book': self.getUse_book_style(), 'margin-top': self.getMargin_top(), 'margin-right': self.getMargin_right(), 'margin-bottom': self.getMargin_bottom(), 'margin-left': self.getMargin_left() } gen_toc = self.getGenerate_toc() if gen_toc: options['toc'] = gen_toc options['toc-header-text'] = translate( toc_msg, context=self.REQUEST) ac_cookie = self.REQUEST.cookies.get('__ac', None) if self.getAllow_cookie() and ac_cookie is not None: options['cookie'] = ['__ac', ac_cookie] return options
def make_options(self): """ Returns a dictionnary of options that can be used in the tool. """ if self.pdf_generator == 'pisa': return {} toc_msg = _(u'label_toc', default = u'Table of content') return {'book': self.getUse_book_style(), 'toc': self.getGenerate_toc(), 'margin-top': self.getMargin_top(), 'margin-right': self.getMargin_right(), 'margin-bottom': self.getMargin_bottom(), 'margin-left': self.getMargin_left(), 'toc-header-text': translate(toc_msg, context = self.REQUEST)}
from zope.interface import Interface, implements import config from collective.sendaspdf import SendAsPDFMessageFactory as _ class ISendAsPDFTool(Interface): """send as pdf tool marker interface""" sendAsPDFSchema = ATDocumentSchema.copy() + atapi.Schema(( atapi.StringField( name = 'pdf_generator', default='wk', widget=atapi.SelectionWidget( format="select", label=_(u'label_pdf_generator', default=u'PDF generator'), ), vocabulary = '_generatorVocabulary' ), atapi.StringField( name = 'tempdir', default='/tmp', widget=atapi.StringWidget( label=_(u'label_export_dir', default=u'Directory where PDF files will be stored'), ), ), atapi.LinesField( name = 'excluded_browser_attachment',
import config from collective.sendaspdf import SendAsPDFMessageFactory as _ class ISendAsPDFTool(Interface): """send as pdf tool marker interface""" sendAsPDFSchema = ATDocumentSchema.copy() + atapi.Schema(( atapi.StringField( name='pdf_generator', default='wk', widget=atapi.SelectionWidget( format="select", label=_(u'label_pdf_generator', default=u'PDF generator')), vocabulary='_generatorVocabulary'), atapi.StringField( name='tempdir', default='/tmp', widget=atapi.StringWidget( label=_(u'label_export_dir', default=u'Directory where PDF files will be stored'))), atapi.LinesField( name='excluded_browser_attachment', default=[], widget=atapi.LinesWidget( label=_(u'label_excluded_browsersattachments', default=u'List of browsers for which PDF '