Kai Diefenbach avatar Kai Diefenbach committed 95d8572

Fixed product filtering for product management views; #issue 142

Comments (0)

Files changed (1)

lfs/manage/views/product/product.py

     """Displays an overview list of all products.
     """
     products = _get_filtered_products(request)
-    paginator = Paginator(products, 20)
+    amount = _get_stored_amount(request)
+    paginator = Paginator(products, amount)
     page = paginator.page(request.REQUEST.get("page", 1))
 
     return render_to_response(template_name, RequestContext(request, {
     """Sets the displayed product page.
     """
     product_id = request.GET.get("product-id")
-    products = _get_filtered_products_for_product_view(request)
-    paginator = Paginator(products, 20)
+
+    print product_id
+    if product_id == "0":
+        # products overview
+        products = _get_filtered_products(request)
+        amount = _get_stored_amount(request)
+    else:
+        # product view
+        products = _get_filtered_products_for_product_view(request)
+        amount = 25
+
+    paginator = Paginator(products, amount)
     page = paginator.page(request.REQUEST.get("page", 1))
 
     html = (
     products = products.order_by("%s%s" % (product_ordering_order, product_ordering))
 
     return products
+
+
+def _get_stored_amount(request):
+    product_filters = request.session.get("product_filters", {})
+    try:
+        return int(product_filters.get("amount", 25))
+    except TypeError:
+        return 25
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.