Prototype of bcmagic search plugin.
[htsworkflow.git] / htsworkflow / frontend / inventory / bcmagic.py
1 from htsworkflow.frontend.inventory.models import Item
2
3 from django.core.exceptions import ObjectDoesNotExist
4
5 def item_search(search):
6     """
7     Searches 
8     """
9     hits = []
10     try:
11         item = Item.objects.get(uuid=search)
12     except ObjectDoesNotExist:
13         item = None
14     
15     if item is not None:
16         hits.append((str(item), item.get_absolute_url()))
17     
18     try:
19         item = Item.objects.get(barcode_id=search)
20     except ObjectDoesNotExist:
21         item = None
22     
23     if item is not None:
24         hits.append((str(item), item.get_absolute_url()))
25
26     return hits