示例#1
0
    def __init__(
        self,
        request,
        template,
        context=None,
        content_type=None,
        status=None,
        mimetype=None,
        current_app=None,
        charset=None,
        using=None,
    ):
        template2 = None
        context["template"] = template
        if context and "view" in context and context["view"]:
            template2 = self._get_model_template(context,
                                                 context["view"].doc_type())

        if not template2:
            if context and "view" in context and context["view"].doc_type(
            ) == "pdf":
                template2 = []
                if "template_name" in context:
                    template2.append(context["template_name"] + ".html")
                for pos in template:
                    template2.append(pos.replace(".html", "_pdf.html"))
                template2.append("schsys/table_pdf.html")
            elif context and "view" in context and context["view"].doc_type(
            ) == "txt":
                template2 = []
                if "template_name" in context:
                    template2.append(context["template_name"] + ".html")
                for pos in template:
                    template2.append(pos.replace(".html", "_txt.html"))
            elif context and "view" in context and context["view"].doc_type(
            ) == "odf":
                template2 = []
                if "template_name" in context:
                    template2.append(context["template_name"] + ".ods")
                for pos in template:
                    template2.append(pos.replace(".html", ".ods"))
                template2.append("schsys/table.ods")
            elif context and "view" in context and context["view"].doc_type(
            ) == "xlsx":
                template2 = []
                if "template_name" in context:
                    template2.append(context["template_name"] + ".xlsx")
                for pos in template:
                    template2.append(pos.replace(".html", ".xlsx"))
                template2.append("schsys/table.xlsx")
            else:
                template2 = template

        if hasattr(template2, "template"):
            LOGGER.info("template: " + str(template2.template.name))
        else:
            LOGGER.info("templates: " + str(template2))
        TemplateResponse.__init__(self, request, template2, context,
                                  content_type, status, current_app)
示例#2
0
    def __init__(self, request, template, context=None, content_type=None, status=None, mimetype=None,
                 current_app=None, charset=None, using=None):

        template2 = None
        if context and 'view' in context and context['view']:
            template2 = self._get_model_template(context, context['view'].doc_type())

        if not template2:
            if context and 'view' in context and context['view'].doc_type()=='pdf':
                template2 = []
                if 'template_name' in context:
                    template2.append(context['template_name']+'.html')
                for pos in template:
                    template2.append(pos.replace('.html', '_pdf.html'))
                template2.append("schsys/table_pdf.html")
            elif context and 'view' in context and context['view'].doc_type()=='txt':
                template2 = []
                if 'template_name' in context:
                    template2.append(context['template_name']+'.html')
                for pos in template:
                    template2.append(pos.replace('.html', '_txt.html'))
            elif context and 'view' in context and context['view'].doc_type()=='odf':
                template2 = []
                if 'template_name' in context:
                    template2.append(context['template_name']+'.ods')
                for pos in template:
                    template2.append(pos.replace('.html', '.ods'))
                template2.append("schsys/table.ods")
            elif context and 'view' in context and context['view'].doc_type()=='xlsx':
                template2 = []
                if 'template_name' in context:
                    template2.append(context['template_name']+'.xlsx')
                for pos in template:
                    template2.append(pos.replace('.html', '.xlsx'))
                template2.append("schsys/table.xlsx")
            else:
                template2 = template

        #try:
        #    TemplateResponse.__init__(self, request, template2, context,
        #                              content_type, status, current_app, charset=charset, using=using)
        #except:
        TemplateResponse.__init__(self, request, template2, context, content_type, status, current_app)
示例#3
0
    def __init__(self, request, template, context=None, content_type=None, status=None, mimetype=None,
                 current_app=None, charset=None, using=None):

        template2 = None
        if context and 'view' in context and context['view']:
            template2 = self._get_model_template(context, context['view'].doc_type())

        if not template2:
            if context and 'view' in context and context['view'].doc_type()=='pdf':
                template2 = []
                if 'template_name' in context:
                    template2.append(context['template_name']+'.html')
                for pos in template:
                    template2.append(pos.replace('.html', '_pdf.html'))
                template2.append("schsys/table_pdf.html")
            elif context and 'view' in context and context['view'].doc_type()=='txt':
                template2 = []
                if 'template_name' in context:
                    template2.append(context['template_name']+'.html')
                for pos in template:
                    template2.append(pos.replace('.html', '_txt.html'))
            elif context and 'view' in context and context['view'].doc_type()=='odf':
                template2 = []
                if 'template_name' in context:
                    template2.append(context['template_name']+'.ods')
                for pos in template:
                    template2.append(pos.replace('.html', '.ods'))
                template2.append("schsys/table.ods")
            elif context and 'view' in context and context['view'].doc_type()=='xlsx':
                template2 = []
                if 'template_name' in context:
                    template2.append(context['template_name']+'.xlsx')
                for pos in template:
                    template2.append(pos.replace('.html', '.xlsx'))
                template2.append("schsys/table.xlsx")
            else:
                template2 = template

        #try:
        #    TemplateResponse.__init__(self, request, template2, context,
        #                              content_type, status, current_app, charset=charset, using=using)
        #except:
        TemplateResponse.__init__(self, request, template2, context, content_type, status, current_app)