Add site scoped documents to the Site menu
authorSverre Rabbelier <srabbelier@gmail.com>
Sun, 07 Dec 2008 17:02:32 +0000
changeset 706 19f55eb5f194
parent 705 0ab17e14df95
child 707 26a95753cd99
Add site scoped documents to the Site menu This allows for featured documents that belong to the Site scope to show up in the 'Site' menu. Patch by: Sverre Rabbelier
app/soc/views/models/site.py
--- a/app/soc/views/models/site.py	Sun Dec 07 17:02:10 2008 +0000
+++ b/app/soc/views/models/site.py	Sun Dec 07 17:02:32 2008 +0000
@@ -26,6 +26,7 @@
 
 from soc.logic import dicts
 from soc.views.helper import access
+from soc.views.models import document as document_view
 from soc.views.models import presence
 
 import soc.models.site
@@ -110,6 +111,25 @@
 
     super(View, self).__init__(params=params)
 
+  def getSidebarMenus(self, request, params=None):
+    """See base.View.getSidebarMenus.
+
+    Returns a custom sidebar entry for the 'site' singleton.
+    """
+
+    entity = self._logic.getFromFields(link_id=self._logic.DEF_SITE_LINK_ID)
+
+    submenus = []
+
+    if entity:
+      submenus = document_view.view.getMenusForScope(entity, self._params)
+
+    new_params = {}
+    new_params['sidebar_additional'] = submenus
+
+    params = dicts.merge(params, new_params)
+    return super(View, self).getSidebarMenus(request, params=params)
+
   def mainPublic(self, request, page_name=None, **kwargs):
     """Displays the main site settings page.