Commits

Steve Losh committed ec68c02 Merge

Merge.

Comments (0)

Files changed (3)

 
     class Media:
         css = {
-            'all': ('stoat.css',),
+            'all': ('stoat.css',) + getattr(settings, 'STOAT_ADMIN_EXTRA_CSS', ()),
         }
-        js = ('stoat.js',)
+        js = ('stoat.js',) + getattr(settings, 'STOAT_ADMIN_EXTRA_JS', ())
 admin.site.register(Page, PageAdmin)
 
 
     def nav_children(self):
         """Return a list of child Page objects."""
         return list(self.get_children().filter(show_in_nav=True))
+        
+    def nav_next_sibling(self):
+        """ Return the next sibling object, or None if it was the rightmost sibling."""
+        siblings = self.nav_siblings()
+        next_sibling = None
+        for i, sibling in enumerate(siblings):
+            if sibling == self and i < len(siblings) - 1:
+                next_sibling = siblings[i+1]
+        return next_sibling   
+        
+    def nav_prev_sibling(self):
+        """ Return the previous sibling object, or None if it was the leftmost sibling."""
+        siblings = self.nav_siblings()
+        prev_sibling = None
+        for i, sibling in enumerate(siblings):
+            if sibling == self and i > 0:
+                prev_sibling = siblings[i-1]
+        return prev_sibling 
 
     def nav_siblings_and_children(self):
         """Return a nested list of sibling/children Page objects (including this page)."""

stoat/tests/test_navigation.py

         real_sibs = set(['/top-one/one-sub/'])
         test_sibs = set([p.url for p in page.nav_siblings()])
         self.assertTrue(real_sibs == test_sibs)
+        
+    def test_nav_next_sibling(self):
+        page = get(Page, url='/')
+        real_sibs = set(['/', '/top-one/', '/top-two/'])
+        real_next_sib = '/top-one/'
+        self.assertTrue(real_next_sib == page.nav_next_sibling().url)
+        
+        page = get(Page, url='/top-two/')
+        real_next_sib = None
+        self.assertTrue(real_next_sib == page.nav_next_sibling())
+        
+    def test_nav_prev_sibling(self):
+        page = get(Page, url='/')
+        real_sibs = set(['/', '/top-one/', '/top-two/'])
+        real_prev_sib = None
+        self.assertTrue(real_prev_sib == page.nav_prev_sibling())
+        
+        page = get(Page, url='/top-two/')
+        real_sibs = set(['/', '/top-one/', '/top-two/'])
+        real_prev_sib = '/top-one/'
+        self.assertTrue(real_prev_sib == page.nav_prev_sibling().url)
 
     def test_nav_children(self):
         page = get(Page, url='/')
         real_kids = set(['/top-one/one-sub/one-sub-sub/'])
         test_kids = set([p.url for p in page.nav_children()])
         self.assertTrue(real_kids == test_kids)
+        
     def test_nav_siblings_and_children(self):
         def test_siblings(saclist, urllist):
             urls = set([sib.url for sib, children in saclist])
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.