예제 #1
0
 def getAvailableTemplates(self):
     """
     Returns a DisplayList with the available templates found in
     browser/templates/samplesprint
     """
     this_dir = os.path.dirname(os.path.abspath(__file__))
     templates_dir = os.path.join(this_dir, self._TEMPLATES_DIR)
     tempath = '%s/%s' % (templates_dir, '*.pt')
     templates = [t.split('/')[-1] for t in glob.glob(tempath)]
     out = []
     for template in templates:
         out.append({'id': template, 'title': template[:-3]})
     for templates_resource in iterDirectoriesOfType(
             self._TEMPLATES_ADDON_DIR):
         prefix = templates_resource.__name__
         templates = [
             tpl for tpl in templates_resource.listDirectory()
             if tpl.endswith('.pt')
         ]
         for template in templates:
             out.append({
                 'id': '{0}:{1}'.format(prefix, template),
                 'title': '{0} ({1})'.format(template[:-3], prefix),
             })
     return out
예제 #2
0
 def getAvailableTemplates(self):
     """
     Returns a DisplayList with the available templates found in
     browser/templates/samplesprint
     """
     this_dir = os.path.dirname(os.path.abspath(__file__))
     templates_dir = os.path.join(this_dir, self._TEMPLATES_DIR)
     tempath = '%s/%s' % (templates_dir, '*.pt')
     templates = [t.split('/')[-1] for t in glob.glob(tempath)]
     out = []
     for template in templates:
         out.append({'id': template, 'title': template[:-3]})
     for templates_resource in iterDirectoriesOfType(
             self._TEMPLATES_ADDON_DIR):
         prefix = templates_resource.__name__
         templates = [
             tpl for tpl in templates_resource.listDirectory()
             if tpl.endswith('.pt')
             ]
         for template in templates:
             out.append({
                 'id': '{0}:{1}'.format(prefix, template),
                 'title': '{0} ({1})'.format(template[:-3], prefix),
             })
     return out