class PDFSchemaExtender(object): """ Schema extender """ implements(ISchemaExtender, IBrowserLayerAwareExtender) layer = ILayer fields = ( ExtendedStringField( name='pdfTheme', schemata='settings', default='', write_permission="Can customize PDF", vocabulary_factory='eea.pdf.vocabulary.Themes', widget=public.SelectionWidget( label=_(u"PDF Theme"), description=_( u"Disable PDF export or override theme used to export " u"this content as PDF." ) ) ), ) def __init__(self, context): self.context = context def getFields(self): """ Returns provenance list field """ if IPDFTool.providedBy(self.context): return [] if IPDFTheme.providedBy(self.context): return [] return self.fields
class IExtraSettings(model.Schema): """ Extra settings """ pdf = schema.Bool(title=_(u"PDF"), description=_(u"Invalidate latest generated PDF file"), required=False, default=False)
def period(self): """ Wait period """ ptype = getattr(self.context, 'portal_type', '') if ptype.lower() in ('collection', 'topic', 'folder', 'atfolder'): return _(u"minutes") return _(u"seconds")
class DownloadFromEmail(BaseSubstitution): """ Download from name """ category = _(u'Download') description = _(u'Download from email') def safe_call(self): """ Safe call """ return getattr(self.context, 'from_email', '')
class DownloadTitle(BaseSubstitution): """ Download title substitution """ category = _(u'Download') description = _(u'Download title') def safe_call(self): """ Safe call """ return getattr(self.context, 'title', '')
class DownloadError(BaseSubstitution): """ Download error """ category = _(u'Download') description = _(u'Download error') def safe_call(self): """ Safe call """ return getattr(self.context, 'error', '')
class DownloadCameFromUrl(BaseSubstitution): """ Download email substitution """ category = _(u'Download') description = _(u'Download came from URL') def safe_call(self): """ Safe call """ return getattr(self.context, 'url', '')
class DownloadEmail(BaseSubstitution): """ Download email substitution """ category = _(u'Download') description = _(u'Download e-mail') def safe_call(self): """ Safe call """ return getattr(self.context, 'email', '')
class PDFSchemaExtender(object): """ Schema extender """ implements(ISchemaExtender, IBrowserLayerAwareExtender) layer = ILayer fields = ( ExtendedStringField( name='pdfTheme', schemata='settings', default='', write_permission="Can customize PDF", vocabulary_factory='eea.pdf.vocabulary.Themes', widget=public.SelectionWidget( label=_(u"PDF Theme"), description=_( u"Disable PDF export or override theme used to export " u"this content as PDF." ) ) ), ExtendedIntegerField('tocdepth', schemata='settings', default=4, write_permission="Can customize PDF", widget=public.SelectionWidget( label=_(u"Table of contents depth level"), description=_( u"Which header tags should be taken into " u"consideration for the table of contents." ) ), vocabulary=IntDisplayList([(0, 'TOC Disabled'), (1, 'H1'), (2, 'H1,H2'), (3, 'H1,H2,H3'), (4, 'H1,H2,H3,H4')]) ), ) def __init__(self, context): self.context = context def getFields(self): """ Returns provenance list field """ if IPDFTool.providedBy(self.context): return [] if IPDFTheme.providedBy(self.context): return [] return self.fields
class CollectionSchemaExtender(PDFSchemaExtender): """ Schema extender """ implements(ISchemaExtender, IBrowserLayerAwareExtender) layer = ILayer fields = ( ExtendedIntegerField( name='pdfMaxDepth', schemata='settings', write_permission="Can customize PDF", widget=public.IntegerWidget( label=_(u"PDF Maximum depth"), description=_( u"Maximum depth to recursively include children items " u"while generating PDF. Leave it empty to use the portal " u"global defined value." ) ) ), ExtendedIntegerField( name='pdfMaxBreadth', schemata='settings', write_permission="Can customize PDF", widget=public.IntegerWidget( label=_(u"PDF Maximum breadth"), description=_( u"Maximum children items to include " u"while generating PDF for collection " u"or folderish content-types where object is collection or " u"folderish. Leave it empty to use the portal " u"global defined value." ) ) ), ExtendedIntegerField( name='pdfMaxItems', schemata='settings', write_permission="Can customize PDF", widget=public.IntegerWidget( label=_(u"PDF Maximum items"), description=_( u"Total maximum children items to be included" u"while generating PDF. Leave it empty to use the portal " u"global defined value." ) ) ), ExtendedImageField( name='coverImage', schemata='settings', write_permission="Can customize PDF", widget=ImageWidget( label=_(u"PDF cover main image"), description=_( u"Main cover image that will show up on the pdf cover page" ) ) ), )
def finish(self, email=''): """ Finish download """ if email: self._email = email self._title = _( u"An email will be sent to you when the PDF is ready") self._message = _( u"If you don't have access to your email address " u"check <a href='${link}'>this link</a> in a few ${period}.", mapping={ u"link": u"%s?direct=1" % self.link(), u"period": self.period() }) return self._redirect()
def finish(self, email=''): """ Finish download """ if email: self._email = email self._title = _( u"An email will be sent to you when the PDF is ready" ) self._message = _( u"If you don't have access to your email address " u"check <a href='${link}'>this link</a> in a few ${period}.", mapping={ u"link": u"%s?direct=1" % self.link(), u"period": self.period() }) return self._redirect()
def __init__(self, context, request): super(Download, self).__init__(context, request) self._title = '' self._message = _( u"* The email is only used for the purpose of sending the PDF. " u"We do not store it for any other use.") self._email = '' self._link = ''
def __init__(self, context, request): super(Download, self).__init__(context, request) self._title = '' self._message = _( u"* The email is only used for the purpose of sending the PDF. " u"We do not store it for any other use." ) self._email = '' self._link = ''
def __init__(self, context, request): import pdb pdb.set_trace() super(MakePdf, self).__init__(context, request) self._title = '' self._message = _( u"* The email is only used for the purpose of sending the PDF. " u"We do not store it for any other use.") self._email = '' self._link = ''
def title(self): """ Title """ if self._title: return self._title title = self.context.title_or_id() if isinstance(title, str): title = title.decode('utf-8') return _( u"Enter your email address where to send '${title}' PDF when ready", mapping={'title': title})
def finish(self, email=''): """ Finish download """ self._email = email return self._redirect( _( u"The PDF is being generated. " u"An email will be sent to you when the PDF is ready. " u"If you don't have access to your email address " u"check <a href='${link}'>this link</a> in a few ${period}.", mapping={ "link": self.link(), "period": self.period() }))
def title(self): """ Title """ if self._title: return self._title title = self.context.title_or_id() if isinstance(title, str): title = title.decode('utf-8') return _( u"Enter your email address where to send '${title}' PDF when ready", mapping={ 'title': title } )
""" EEA Relations Content Type """ from zope.interface import implementer from Products.Archetypes import atapi from Products.ATContentTypes.content.folder import ATFolder from eea.pdf.content.interfaces import IPDFTheme from eea.pdf.config import EEAMessageFactory as _ EditSchema = atapi.Schema(( atapi.StringField('cover', schemata='default', default='pdf.cover', widget=atapi.StringWidget( label=_(u"Cover"), description=_( u"A page template to be used for PDF Cover. " u"Leave empty to disable it." ) ) ), atapi.StringField('disclaimer', schemata='default', default='pdf.disclaimer', widget=atapi.StringWidget( label=_(u"Disclaimer"), description=_( u"A page template to be used for PDF Disclaimer, " u"the first page after PDF cover. " u"Leave empty to disable it." )
""" EEA Relations Content Type """ from zope.interface import implementer from Products.Archetypes import atapi from Products.ATContentTypes.content.folder import ATFolder from plone.app.blob.field import ImageField from eea.pdf.content.interfaces import IPDFTheme from eea.pdf.config import EEAMessageFactory as _ from archetypes.referencebrowserwidget import ReferenceBrowserWidget EditSchema = atapi.Schema(( atapi.StringField('cover', schemata='default', default='pdf.cover', widget=atapi.StringWidget( label=_(u"Cover"), description=_( u"A page template to be used for PDF Cover. " u"Leave empty to disable it."))), atapi.BooleanField( 'coverSubtitle', schemata='default', default=True, widget=atapi.BooleanWidget( label=_(u"Cover subtitle"), description=_(u"Enable display of subtitle within cover page." u" By default subtitle is created from content" u" description truncated to first 70 characters"))), atapi.StringField( 'disclaimer', schemata='default',
""" EEA Relations Content Type """ from zope.interface import implementer from Products.Archetypes import atapi from Products.ATContentTypes.content.folder import ATFolder from plone.app.blob.field import ImageField from eea.pdf.content.interfaces import IPDFTheme from eea.pdf.config import EEAMessageFactory as _ from archetypes.referencebrowserwidget import ReferenceBrowserWidget EditSchema = atapi.Schema(( atapi.StringField('cover', schemata='default', default='pdf.cover', widget=atapi.StringWidget( label=_(u"Cover"), description=_( u"A page template to be used for PDF Cover. " u"Leave empty to disable it." ) ) ), atapi.BooleanField('coverSubtitle', schemata='default', default=True, widget=atapi.BooleanWidget( label=_(u"Cover subtitle"), description=_(u"Enable display of subtitle within cover page." u" By default subtitle is created from content" u" description truncated to first 70 characters" )