aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--servo/forms/product.py5
-rw-r--r--servo/views/product.py7
2 files changed, 12 insertions, 0 deletions
diff --git a/servo/forms/product.py b/servo/forms/product.py
index 227a9b3..08fb71a 100644
--- a/servo/forms/product.py
+++ b/servo/forms/product.py
@@ -53,6 +53,11 @@ class ProductSearchForm(forms.Form):
label=_('Device model is'),
queryset=TaggedItem.objects.none()
)
+ location = forms.ModelChoiceField(
+ required=False,
+ label=_('Location is'),
+ queryset=Location.objects.filter(enabled=True)
+ )
def __init__(self, *args, **kwargs):
super(ProductSearchForm, self).__init__(*args, **kwargs)
diff --git a/servo/views/product.py b/servo/views/product.py
index 70f6b63..a614819 100644
--- a/servo/views/product.py
+++ b/servo/views/product.py
@@ -34,6 +34,9 @@ def prep_list_view(request, group='all'):
if group == 'all':
group = ProductCategory(title=_('All'), slug='all')
+ elif group == 'None':
+ group = ProductCategory(title=_('None'), slug='none')
+ all_products = all_products.filter(categories=None)
else:
group = categories.get(slug=group)
all_products = group.get_products()
@@ -60,6 +63,10 @@ def prep_list_view(request, group='all'):
tag = tag.tag
title += u" / %s" % tag
all_products = all_products.filter(tags__tag=tag)
+
+ location = fdata.get('location')
+ if location:
+ all_products = all_products.filter(inventory__contains=location.pk)
else:
form = ProductSearchForm()