A patch that allows printing more than 11 labels at a time.
authorBrandon King <kingb@caltech.edu>
Fri, 14 May 2010 22:43:22 +0000 (22:43 +0000)
committerBrandon King <kingb@caltech.edu>
Fri, 14 May 2010 22:43:22 +0000 (22:43 +0000)
htsworkflow/frontend/bcmagic/utils.py
htsworkflow/frontend/samples/admin.py

index ee35268dbc85d4156c19f6903130a3427d761aa6..e7d89d36e132eb1bece6b687304fc163a2a507ad 100644 (file)
@@ -18,7 +18,15 @@ def print_zpl(zpl_text, host=settings.BCPRINTER_PRINTER1_HOST):
 def print_zpl_socket(zpl_text, host=settings.BCPRINTER_PRINTER1_HOST, port=settings.BCPRINTER_PRINTER1_PORT):
     """
     Sends zpl_text to printer via a socket
+    
+    if zpl_text is a list of zpl_texts, it will print each one
+    in that list.
     """
+    
+    # Process anyway if zpl_text is a list.
+    if type(zpl_text) is list:
+        zpl_text = '\n'.join(zpl_text)
+    
     s = socket.socket()
     # PORT 9100 is default for Zebra tabletop/desktop printers
     # PORT 6101 is default for Zebra mobile printers
index 345e32ac4167723caa52873f4275267ed915ebe4..9295175c3f0cfe43fb96ada1ab64bdcac4cdb8ac 100644 (file)
@@ -183,6 +183,7 @@ class LibraryOptions(admin.ModelAdmin):
         # ZPL Template
         t = Template(template.template)
         
+        zpl_list = []
         #Iterate over selected labels to print
         for library in queryset.all():
             
@@ -191,7 +192,9 @@ class LibraryOptions(admin.ModelAdmin):
             
             # Send rendered template to the printer that the template
             #  object has been attached to in the database.
-            print_zpl_socket(t.render(c), host=template.printer.ip_address)
+            zpl_list.append(t.render(c))
+        
+        print_zpl_socket(zpl_list, host=template.printer.ip_address)
     
         self.message_user(request, "%s labels printed." % (len(queryset)))