Added ability to print container labels.
[htsworkflow.git] / samplebc / samples / views.py
index 32a69c05c73554248d623cc2e5e64d5d03017467..161ca0dfb90eaa7e663644b0a5fa71bff972ec5b 100644 (file)
@@ -200,6 +200,30 @@ def container_edit(request, container_id):
     })
 
 
+def container_print(request, container_id):
+    """
+    prints a container label
+    """
+    
+    try:
+        container = models.Container.objects.get(uuid=container_id)
+    except ObjectDoesNotExist:
+        return HttpResponse('Container (%s) does not exist!' % (container_id))
+    
+    params = {}
+    params['line1'] = __center_line('', 10)
+    params['line2'] = __center_line('', 14)
+    params['line3'] = __center_line('%s' % (container.name[16:16+15]), 15)
+    params['container_name'] = __center_line(container.name[0:16], 16)
+    params['barcode'] = 'cntr|%s' % (container.uuid)
+    params['symbol'] = ''
+    
+    c = Context(params)
+    t = get_template('zpl_container_label.txt')
+    print_zpl(t.render(c))
+    
+    return HttpResponse('print command for container %s sent.' % (container.uuid))
+
 
 ################################################
 # Freezer