+
+def _item_print(item, request):
+ """
+ Prints an item given a type of item label to print
+ """
+ #FIXME: Hard coding this for now... need to abstract later.
+ context = {'item': item}
+
+ # Print using barcode_id
+ if not item.force_use_uuid and (item.barcode_id is None or len(item.barcode_id.strip())):
+ context['use_uuid'] = False
+ msg = 'Printing item with barcode id: %s' % (item.barcode_id)
+ # Print using uuid
+ else:
+ context['use_uuid'] = True
+ msg = 'Printing item with UUID: %s' % (item.uuid)
+
+ c = RequestContext(request, context)
+ t = get_template(getTemplateByType(item.item_type.name))
+ print_zpl_socket(t.render(c))
+
+ return msg
+
+@login_required
+def item_print(request, uuid):
+ """
+ Print a label for a given item
+ """
+ try:
+ item = Item.objects.get(uuid=uuid)
+ except ObjectDoesNotExist, e:
+ item = None
+ msg = "Item with UUID %s does not exist" % (uuid)
+
+ if item is not None:
+ msg = _item_print(item, request)
+
+ return item_summary(request, uuid, msg)
+
+