Exemplo n.º 1
0
class ISOfficeSettings(Interface):

    port = ASCIILine(title=_(u"LibreOffice port"),
                     description=_(u"The port used by LibreOffice service"))

    host = Int(title=_(u"LibreOffice host"),
               description=_(u"The hostname from where LibreOffice is served"))
Exemplo n.º 2
0
    def __call__(self):
        context = self.context
        annotations = IAnnotations(context)
        status = annotations.get(STATUS_STORAGE_KEY, None)
        named_file = annotations.get(DATA_STORAGE_KEY, None)
        if status == TASK_SUCCEEDED:
            set_headers(named_file,
                        self.request.response,
                        filename=named_file.filename)
            return stream_data(named_file)

        if status == TASK_IN_PROGRESS:
            IStatusMessage(self.request).add(
                _(u"Document generation in progress, please retry later..."),
                type='warning')
        elif status == TASK_FAILED:
            IStatusMessage(self.request).add(_(
                u"Document generation failed, please retry document generation or contact your administrator..."
            ),
                                             type='error')
        elif not status or not named_file:
            IStatusMessage(self.request).add(_(u"No document generated here"),
                                             type='error')

        self.request.response.redirect(self.context.absolute_url() + '/view')
    def render(self):
        context = self.context
        annotations = IAnnotations(context)
        status = annotations.get(STATUS_STORAGE_KEY, None)
        named_file = annotations.get(DATA_STORAGE_KEY, None)
        if status == TASK_IN_PROGRESS:
            return PORTAL_MESSAGE % {'statusid': 'info',
                                     'status': PMF(u"Info"),
                                     'msg': _(u"Processing document generation, please refresh the page...")}
        elif status == TASK_FAILED:
            return PORTAL_MESSAGE % {'statusid': 'warning',
                                     'status': PMF(u"Error"),
                                     'msg': _(u"Document generation failed, please retry or contact your administrator")}
        elif not status:
            return u""

        url = u"%s/getdocumentfusion" % context.absolute_url()
        title = translate(_(u"Get the generated file."), context=self.request)

        mtregistry = getToolByName(self.context, 'mimetypes_registry')
        file_name = named_file.filename
        mimetype = mtregistry.lookupExtension(file_name)
        icon_path = "%s/%s" % (self.portal_url, mimetype.icon_path)
        return u"""
        <div id="generated-pdf">
          <a href="%s" title="%s">
            <img src="%s" /> %s
          </a>
        </div>""" % (url, title, icon_path, file_name)
Exemplo n.º 4
0
    def render(self):
        context = self.context
        annotations = IAnnotations(context)
        status = annotations.get(STATUS_STORAGE_KEY, None)
        named_file = annotations.get(DATA_STORAGE_KEY, None)
        if status == TASK_IN_PROGRESS:
            return PORTAL_MESSAGE % {
                'statusid':
                'info',
                'status':
                PMF(u"Info"),
                'msg':
                translate(_(
                    u"Processing document generation, please refresh the page..."
                ),
                          context=self.request)
            }
        elif status == TASK_FAILED:
            return PORTAL_MESSAGE % {
                'statusid':
                'warning',
                'status':
                PMF(u"Error"),
                'msg':
                translate(_(
                    u"Document generation failed, please retry or contact your administrator"
                ),
                          context=self.request)
            }
        elif not status:
            return u""

        url = u"%s/getdocumentfusion" % context.absolute_url()
        title = translate(_(u"Get the generated file."), context=self.request)

        mtregistry = getToolByName(self.context, 'mimetypes_registry')
        file_name = named_file.filename
        mimetype = mtregistry.lookupExtension(file_name)
        icon_path = "%s/%s" % (self.portal_url, mimetype.icon_path)
        return u"""
        <div id="generated-pdf">
          <a href="%s" title="%s">
            <img src="%s" /> %s
          </a>
        </div>""" % (url, title, icon_path, file_name)
    def __call__(self):
        context = self.context
        annotations = IAnnotations(context)
        status = annotations.get(STATUS_STORAGE_KEY, None)
        named_file = annotations.get(DATA_STORAGE_KEY, None)
        if status == TASK_SUCCEEDED or not named_file:
            set_headers(named_file,
                        self.request.response, filename=named_file.filename)
            return stream_data(named_file)

        if status == TASK_IN_PROGRESS:
            IStatusMessage(self.request).add(_(u"Document generation in progress, please retry later..."),
                                             type='warning')
        elif status == TASK_FAILED:
            IStatusMessage(self.request).add(_(u"Document generation failed, please retry document generation or contact your administrator..."),
                                             type='error')
        elif not status:
            IStatusMessage(self.request).add(_(u"No document generated here"),
                                             type='error')

        self.request.response.redirect(self.context.absolute_url()+'/view')