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.
from htsworkflow.frontend.samples.changelist import HTSChangeList
from htsworkflow.frontend.inventory.models import Item, LongTermStorage, ItemType
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
from htsworkflow.frontend.inventory.bcmagic import item_search
from htsworkflow.frontend.bcmagic.plugin import register_search_plugin
from htsworkflow.frontend.experiments.models import FlowCell
Inventory Index View
"""
# build changelist
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'],
- model_admin=ItemAdmin(Item, None)
+ model_admin=ItemTypeAdmin(ItemType, None)
'page_name': 'Inventory Index'
}
context_dict.update(INVENTORY_CONTEXT_DEFAULTS)
'page_name': 'Inventory Index'
}
context_dict.update(INVENTORY_CONTEXT_DEFAULTS)
return render_to_response('inventory/inventory_index.html',
context_dict,
context_instance=RequestContext(request))
return render_to_response('inventory/inventory_index.html',
context_dict,
context_instance=RequestContext(request))
def get_query_set(self, request):
qs = super(HTSChangeList, self).get_query_set(request)
def get_query_set(self, request):
qs = super(HTSChangeList, self).get_query_set(request)
if self.extra_filters:
new_qs = qs.filter(**self.extra_filters)
if new_qs is not None:
if self.extra_filters:
new_qs = qs.filter(**self.extra_filters)
if new_qs is not None:
{% block coltype %}flex{% endblock %}
{% block content %}
<div id="inventory-index-div" >
{% 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 %}
{% 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 %}
<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 %}
{% 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>
<thead >
<tr >
<td >Name</td>
- {% 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>
<tr >
<td ><a href="/inventory/it/{{ itemtype.name }}/">{{ itemtype.name }}</a></td>
<td >{{ itemtype.description }}</td>
{% block coltype %}flex{% endblock %}
{% block content %}
<div id="inventory-index-div" >
{% 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 %}
{% 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 %}
<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 %}
{% 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>
<thead >
<tr >
<td >UUID</td>
- {% 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>
<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>