From b0b41b36b41c6a38b4306f9cc19bbfba7fc5f033 Mon Sep 17 00:00:00 2001 From: Brandon King Date: Mon, 6 Jul 2009 22:12:53 +0000 Subject: [PATCH] Updated inventory to support display of inventory items based on uuid/barcode_id scans. --- htsworkflow/frontend/fixtures/bcmagic.xml | 10 +++++ htsworkflow/frontend/inventory/urls.py | 3 +- htsworkflow/frontend/inventory/views.py | 24 +++++++++-- .../inventory/inventory_summary.html | 40 +++++++++++++++++-- 4 files changed, 68 insertions(+), 9 deletions(-) diff --git a/htsworkflow/frontend/fixtures/bcmagic.xml b/htsworkflow/frontend/fixtures/bcmagic.xml index 59dd041..cd9fb97 100644 --- a/htsworkflow/frontend/fixtures/bcmagic.xml +++ b/htsworkflow/frontend/fixtures/bcmagic.xml @@ -25,4 +25,14 @@ (?P<search>[\S\s]+) http://www.flickr.com/search/?q={{ search }} + + invu + (?P<uuid>[A-Fa-f0-9]+) + /inventory/{{ uuid }}/ + + + invb + (?P<barcode_id>.+) + /inventory/{{barcode_id}}/ + diff --git a/htsworkflow/frontend/inventory/urls.py b/htsworkflow/frontend/inventory/urls.py index 4331cb7..49ede61 100644 --- a/htsworkflow/frontend/inventory/urls.py +++ b/htsworkflow/frontend/inventory/urls.py @@ -7,7 +7,8 @@ urlpatterns = patterns('', (r'^lts/link/(?P.+)/(?P.+)/$', 'htsworkflow.frontend.inventory.views.link_flowcell_and_device'), # INDEX - (r'^(?P[a-fA-F0-9]{32})/$', 'htsworkflow.frontend.inventory.views.item_summary'), + (r'^(?P[a-fA-F0-9]{32})/$', 'htsworkflow.frontend.inventory.views.item_summary_by_uuid'), (r'^(?P[a-fA-F0-9]{32})/print/$', 'htsworkflow.frontend.inventory.views.item_print'), + (r'^(?P.+)/$', 'htsworkflow.frontend.inventory.views.item_summary_by_barcode'), (r'^$', 'htsworkflow.frontend.inventory.views.index') ) diff --git a/htsworkflow/frontend/inventory/views.py b/htsworkflow/frontend/inventory/views.py index 7049320..65040a1 100644 --- a/htsworkflow/frontend/inventory/views.py +++ b/htsworkflow/frontend/inventory/views.py @@ -90,15 +90,31 @@ def index(request): context_dict, context_instance=RequestContext(request)) + @login_required -def item_summary(request, uuid, msg=''): +def item_summary_by_barcode(request, barcode_id, msg=''): """ - Display a summary for an item + Display a summary for an item by barcode """ try: - item = Item.objects.get(uuid=uuid) + item = Item.objects.get(barcode_id=barcode_id) except ObjectDoesNotExist, e: item = None + + return item_summary_by_uuid(request, None, msg, item) + + +@login_required +def item_summary_by_uuid(request, uuid, msg='', item=None): + """ + Display a summary for an item + """ + # Use item instead of looking it up if it is passed. + if item is None: + try: + item = Item.objects.get(uuid=uuid) + except ObjectDoesNotExist, e: + item = None context_dict = { 'page_name': 'Item Summary', @@ -149,7 +165,7 @@ def item_print(request, uuid): if item is not None: msg = _item_print(item, request) - return item_summary(request, uuid, msg) + return item_summary_by_uuid(request, uuid, msg) def link_flowcell_and_device(request, flowcell, serial): diff --git a/htsworkflow/frontend/templates/inventory/inventory_summary.html b/htsworkflow/frontend/templates/inventory/inventory_summary.html index 5112c21..00cb6bd 100644 --- a/htsworkflow/frontend/templates/inventory/inventory_summary.html +++ b/htsworkflow/frontend/templates/inventory/inventory_summary.html @@ -2,10 +2,42 @@ {% block content %} {% if item %} -

Item: {{item.uuid}}

- Print - - +

Item Summary:

+ Print
+
+ UUID: {{item.uuid}}
+ Barcode ID: {{ item.barcode_id }}
+ Type: {{ item.item_type.name }}
+
+ Location: {{ item.location.name }}
+ Status: {% if item.status %}{{ item.status.name }}{% else %}N/A{% endif %}
+
+ {% if item.item_info.model_id %} + Model ID: {{ item.item_info.model_id }}
+ {% endif %} + {% if item.item_info.part_number %} + Part Number: {{ item.item_info.part_number }}
+ {% endif %} + {% if item.item_info.lot_number %} + Lot Number: {{ item.item_info.lot_number }}
+ {% endif %} +
+ {% if item.item_info.url %} + Item Website: Link
+ {% endif %} + Vendor: {% if item.item_info.vendor.url %}{% endif %}{{ item.item_info.vendor.name }}{% if item.item_info.vendor.url %}{% endif %}
+ Purchase Date:{% if item.item_info.purchase_date %}{{ item.item_info.purchase_date }}{% else %}N/A{% endif %}
+ Warenty (Months):{% if item.item_info.warenty_months %}{{item.item_info.warenty_months}}{% else %}N/A{% endif %}
+
+ Item Info Notes: +

+ {% if item.item_info.notes %}{{ item.item_info.notes }}{% else %}No notes found{% endif %} +

+
+ Item Specific Notes: +

+ {% if item.notes %}{{ item.notes }}{% else %}No notes found{% endif %} +

{% else %}

Item with UUID of {{ uuid }} not found.

-- 2.30.2