app/soc/views/models/document.py
changeset 705 0ab17e14df95
parent 699 4e8eefe95748
child 710 edb5dbb1dea7
--- a/app/soc/views/models/document.py	Sun Dec 07 17:01:44 2008 +0000
+++ b/app/soc/views/models/document.py	Sun Dec 07 17:02:10 2008 +0000
@@ -33,6 +33,7 @@
 from soc.logic.models import user as user_logic
 from soc.views import helper
 from soc.views.helper import access
+from soc.views.helper import redirects
 from soc.views.models import base
 
 import soc.models.document
@@ -142,6 +143,37 @@
 
     super(View, self)._editGet(request, entity, form)
 
+  def getMenusForScope(self, entity, params):
+    """Returns the featured menu items for one specifc entity.
+
+    A link to the home page of the specified entity is also included.
+
+    Args:
+      entity: the entity for which the entry should be constructed
+      params: a dict with params for this View.
+    """
+
+    filter = {
+        'scope_path': entity.key().name(),
+        'is_featured': True,
+        }
+
+    entities = self._logic.getForFields(filter)
+
+    submenus = []
+
+    # add a link to the home page
+    submenu = (redirects.getPublicRedirect(entity, params), "Home", 'public')
+    submenus.append(submenu)
+
+    # add a link to all featured documents
+    for entity in entities:
+      submenu = (redirects.getPublicRedirect(entity, self._params),
+                 entity.short_name, 'public')
+      submenus.append(submenu)
+
+    return submenus
+
 view = View()
 
 create = view.create