Beispiel #1
0
    def post(self):
        csvfile = self.get_uploads('label-upload')
        key = cgi.escape(self.request.get('label-type'))

        if key and csvfile:
            t = Template.get_by_id(key) or Alias.get_by_id(key)
            if t.__class__ == Alias:
                t = Template.query(Template.aliases == t.key).fetch()[0]
    
            blob = csvfile[0]
            iterator = BlobIterator(blobstore.BlobReader(blob.key()))

            labels = list()
            for row in csv.reader(iterator):
                if row: labels.append(row)
            
            blobstore.delete(blob.key())
            
            template = JINJA_ENVIRONMENT.get_template('labels.html')
            self.response.write(template.render({'key': t.key.string_id(),
                                                 'labels': labels,
                                                 'labels_per_page': int(t.layout.get().nx * t.layout.get().ny),
                                                 'label_barcode': cgi.escape(self.request.get('label-barcode')),
                                                 'label_orientation': cgi.escape(self.request.get('label-orientation')),
                                                 'label_font_size': cgi.escape(self.request.get('label-font-size')),
                                                 }))
        else:
            self.redirect('/') #TODO
Beispiel #2
0
 def get(self):
     upload_url = blobstore.create_upload_url('/upload')
     
     templates, aliases = Template.query().order(Template.key).fetch(), Alias.query().order(Template.key).fetch()
     #templates.extend(aliases)
     templates = [ t.key.string_id() for t in templates ]
     templates.sort()
     
     template = JINJA_ENVIRONMENT.get_template('form.html')
     self.response.write(template.render({'upload_url': upload_url,
                                          'templates': templates}))
Beispiel #3
0
 def get(self, key):
     key = key.replace('.css', '')
     
     t = Template.get_by_id(key) or Alias.get_by_id(key)
     if t.__class__ == Alias:
         t = Template.query(Template.aliases == t.key).fetch()[0]
     
     template = JINJA_ENVIRONMENT.get_template('css/template.css')
     self.response.headers['Content-Type'] = 'text/css'
     self.response.write(template.render({'name': t.key.string_id(),
                                          'paper_width': t.size[0],
                                          'left_margin': t.left_margin,
                                          'top_margin': t.top_margin,
                                          'label_width': t.label_width,
                                          'label_height': t.label_height,
                                          'label_margin_right': t.label_margin_right
                                          }))