diff MoinMoin/items/__init__.py @ 484:19b257c0e102

code to get the subitem index flag has been refactored and moved under items/__init__.py and also unitest is added for the same.
author Akash Sinha <akash2607@gmail.com>
date Sat, 09 Jul 2011 00:11:02 +0530
parents 72899d48db41
children b6149c732926
line wrap: on
line diff
--- a/MoinMoin/items/__init__.py	Fri Jul 08 17:15:53 2011 +0530
+++ b/MoinMoin/items/__init__.py	Sat Jul 09 00:11:02 2011 +0530
@@ -591,6 +591,20 @@
 
     index_template = 'index.html'
 
+    def get_detailed_index(self, index):
+        """ appends a flag in the index of items indicating that the parent has sub items """
+        detailed_index = []
+        all_item_index = self.get_index()
+        all_item_text = "\n".join(item_info[1] for item_info in all_item_index)
+        for fullname, relname, contenttype in index:
+            hassubitem = False
+            subitem_name_re = u"%s/" % re.escape(relname)
+            regex = re.compile(subitem_name_re, re.UNICODE)
+            if regex.search(all_item_text):
+                hassubitem = True
+            detailed_index.append((fullname, relname, contenttype, hassubitem))
+        return detailed_index
+
     def name_initial(self, names=None):
         initials = [(name[1][0])
                    for name in names]