Make the inventory pages work with the new HTSChangeList.
authorDiane Trout <diane@caltech.edu>
Thu, 13 Dec 2012 22:21:52 +0000 (14:21 -0800)
committerDiane Trout <diane@caltech.edu>
Thu, 13 Dec 2012 22:21:52 +0000 (14:21 -0800)
There were a few problems, I was calling get_result_set in the template,
which requires the HTTP request which isn't available. I needed to be using
result_list instead.

I also changed the name in the context and failed to use the right model
for one of the indexes.

htsworkflow/frontend/inventory/views.py
htsworkflow/frontend/samples/changelist.py
htsworkflow/frontend/templates/inventory/inventory_index.html
htsworkflow/frontend/templates/inventory/inventory_itemtype_index.html

index 78b73fd387ce926f18b63b8f1500b0eea5befa2a..265e1bc74f43d74d53957401a20d018c043ac170 100644 (file)
@@ -1,6 +1,6 @@
 from htsworkflow.frontend.samples.changelist import HTSChangeList
 from htsworkflow.frontend.inventory.models import Item, LongTermStorage, ItemType
-from htsworkflow.frontend.inventory.admin import ItemAdmin
+from htsworkflow.frontend.inventory.admin import ItemAdmin, ItemTypeAdmin
 from htsworkflow.frontend.inventory.bcmagic import item_search
 from htsworkflow.frontend.bcmagic.plugin import register_search_plugin
 from htsworkflow.frontend.experiments.models import FlowCell
@@ -162,11 +162,11 @@ def index(request):
     Inventory Index View
     """
     # build changelist
-    item_changelist = HTSChangeList(request, Item,
-        list_filter=['barcode_id',  ],
-        search_fields=[],
+    item_changelist = HTSChangeList(request, ItemType,
+        list_filter=[],
+        search_fields=['name', 'description'],
         list_per_page=50,
-        model_admin=ItemAdmin(Item, None)
+        model_admin=ItemTypeAdmin(ItemType, None)
     )
 
     context_dict = {
@@ -174,7 +174,6 @@ def index(request):
         'page_name': 'Inventory Index'
     }
     context_dict.update(INVENTORY_CONTEXT_DEFAULTS)
-
     return render_to_response('inventory/inventory_index.html',
                               context_dict,
                               context_instance=RequestContext(request))
index 9ae8adf22ee996fff390e3b05747b13055a84a9a..47163052505fa0347cef66a115c4e3067d38725a 100644 (file)
@@ -33,7 +33,6 @@ class HTSChangeList(ChangeList):
 
     def get_query_set(self, request):
         qs = super(HTSChangeList, self).get_query_set(request)
-        print qs
         if self.extra_filters:
             new_qs = qs.filter(**self.extra_filters)
             if new_qs is not None:
index 2eb84abc4ba73d0497610711ebce06a8313e6494..51c6a5999568fd88009783d0f2157e020cc43619 100644 (file)
@@ -18,7 +18,7 @@
 {% block coltype %}flex{% endblock %}
 {% block content %}
 <div id="inventory-index-div" >
-  <div class="module{% if cl.has_filters %} filtered{% endif %}" id="changelist">
+  <div class="module{% if item_changelist.has_filters %} filtered{% endif %}" id="changelist">
     {% block search %}{% search_form item_changelist %}{% endblock %}
  
     {% block pagination %}{% pagination item_changelist %}{% endblock %}
     <div id="changelist-filter">
       <h2 >{% trans 'Filter' %}</h2>
       {% for spec in item_changelist.filter_specs %}
-         {% admin_list_filter cl spec %}
+         {% admin_list_filter item_changelist spec %}
          {% endfor %}
        </div>
     {% endif %}
     {% endblock %}
   {% block summary_stats %}
-  <table class="{% if cl.has_filters %} filtered{% endif %}">
+  <table class="{% if item_changelist.has_filters %} filtered{% endif %}">
     <thead >
       <tr >
         <td >Name</td>
@@ -42,7 +42,7 @@
       </tr>
     </thead>
     <tbody >
-      {% for itemtype in item_changelist.get_query_set %}
+      {% for itemtype in item_changelist.result_list %}
       <tr >
         <td ><a href="/inventory/it/{{ itemtype.name }}/">{{ itemtype.name }}</a></td>
         <td >{{ itemtype.description }}</td>
index 62ebdcef6ed7014eaaa3b8193b17242150797fdd..32975d6df934f8e78b6e19c4d8a0ea17aff70703 100644 (file)
@@ -18,7 +18,7 @@
 {% block coltype %}flex{% endblock %}
 {% block content %}
 <div id="inventory-index-div" >
-  <div class="module{% if cl.has_filters %} filtered{% endif %}" id="changelist">
+  <div class="module{% if item_changelist.has_filters %} filtered{% endif %}" id="changelist">
     {% block search %}{% search_form item_changelist %}{% endblock %}
 
     {% block pagination %}{% pagination item_changelist %}{% endblock %}
     <div id="changelist-filter">
       <h2 >{% trans 'Filter' %}</h2>
       {% for spec in item_changelist.filter_specs %}
-         {% admin_list_filter cl spec %}
+         {% admin_list_filter item_changelist spec %}
          {% endfor %}
     </div>
     {% endif %}
     {% endblock %}
   {% block summary_stats %}
-  <table class="{% if cl.has_filters %} filtered{% endif %}">
+  <table class="{% if item_changelist.has_filters %} filtered{% endif %}">
     <thead >
       <tr >
         <td >UUID</td>
@@ -47,7 +47,7 @@
       </tr>
     </thead>
     <tbody >
-      {% for item in item_changelist.get_query_set %}
+      {% for item in item_changelist.result_list %}
       <tr about="{{ item.get_absolute_url }}">
         <td ><a href="{{ item.get_absolute_url}}" rel="invns:uuid">{{ item.uuid }}</a></td>
         <td ><a href="/inventory/{{ item.barcode_id }}/" rel="invns:barcode">{{ item.barcode_id }}</a></td>