diff MoinMoin/items/__init__.py @ 518:0398d1eb14c1

small change in contenttype filter (now items with unknown mime types have a different filter, as earlier it was shown regardless of the filter selected)
author Akash Sinha <akash2607@gmail.com>
date Fri, 19 Aug 2011 02:26:23 +0530
parents 201758d56fb1
children 6332dda59cb6
line wrap: on
line diff
--- a/MoinMoin/items/__init__.py	Thu Aug 18 23:26:13 2011 +0530
+++ b/MoinMoin/items/__init__.py	Fri Aug 19 02:26:23 2011 +0530
@@ -602,20 +602,35 @@
         else:
             selected_contenttypes = all_contenttypes
 
+        unknown_item_group = "unknown items"
         if startswith:
             startswith = (u'%s' % startswith, u'%s' % startswith.swapcase())
-            index = [(fullname, relname, contenttype)
-                     for fullname, relname, contenttype in index
-                     if u'/' not in relname
-                     and relname.startswith(startswith)
-                     and (contenttype not in all_contenttypes or contenttype in selected_contenttypes)]
-                     # If an item's contenttype not present in the default contenttype list,
-                     # then it will be shown without going through any filter.
+            if not selected_groups or  unknown_item_group in selected_groups:
+                index = [(fullname, relname, contenttype)
+                         for fullname, relname, contenttype in index
+                         if u'/' not in relname
+                         and relname.startswith(startswith)
+                         and (contenttype not in all_contenttypes or contenttype in selected_contenttypes)]
+                         # If an item's contenttype not present in the default contenttype list,
+                         # then it will be shown without going through any filter.
+            else:
+                index = [(fullname, relname, contenttype)
+                         for fullname, relname, contenttype in index
+                         if u'/' not in relname
+                         and relname.startswith(startswith)
+                         and (contenttype in selected_contenttypes)]
+
         else:
-            index = [(fullname, relname, contenttype)
-                     for fullname, relname, contenttype in index
-                     if u'/' not in relname
-                     and (contenttype not in all_contenttypes or contenttype in selected_contenttypes)]
+            if not selected_groups or unknown_item_group in selected_groups:
+                index = [(fullname, relname, contenttype)
+                         for fullname, relname, contenttype in index
+                         if u'/' not in relname
+                         and (contenttype not in all_contenttypes or contenttype in selected_contenttypes)]
+            else:
+                index = [(fullname, relname, contenttype)
+                         for fullname, relname, contenttype in index
+                         if u'/' not in relname
+                         and contenttype in selected_contenttypes]
 
         return index