app/soc/views/models/base.py
changeset 614 53a3e46fc512
parent 613 4880ffa9f3ba
child 615 1d09147de51f
--- a/app/soc/views/models/base.py	Sat Nov 29 19:44:48 2008 +0000
+++ b/app/soc/views/models/base.py	Sat Nov 29 19:45:19 2008 +0000
@@ -543,119 +543,29 @@
 
     return helper.responses.respond(request, template, context)
 
-  def _getSidebarItems(self, params):
-    """Retrieves a list of sidebar entries for this view
-
-    Params usage:
-      The params dictionary is provided to the menu_text's format.
-
-      sidebar: The sidebar value is returned directly if non-False
-      sidebar_defaults: The sidebar_defaults are used to construct the
-        sidebar items for this View. It is expected to be a tuple of
-        three items, the item's url, it's menu_text, and it's
-        access_type, see getSidebarLinks on how access_type is used.
-      sidebar_additional: The sidebar_additional values are appended
-        to the list of items verbatim, and should be in the format
-        expected by getSidebarLinks.
-
-    Args:
-      params: a dict with params for this View.
-    """
-
-    # Return the found result
-    if params['sidebar']:
-      return params['sidebar']
-
-    # Construct defaults manualy
-    defaults = params['sidebar_defaults']
-
-    result = []
-
-    for url, menu_text, access_type in defaults:
-      url = url % params['url_name'].lower()
-      item = (url, menu_text % params, access_type)
-      result.append(item)
-
-    for item in params['sidebar_additional']:
-      result.append(item)
-
-    return result
-
   def getSidebarLinks(self, request, params=None):
     """Returns an dictionary with one sidebar entry.
 
-    Calls _getSidebarItems to retrieve the items that should be in the
-    menu. Expected is a tuple with an url, a menu_text, and an
-    access_type. The access_type is then passed to checkAccess, if it
-    raises out_of_band.Error, the item will not be added.
-
     Args:
       request: the django request object
       params: a dict with params for this View
 
     Params usage:
-      The params dictionary is passed as argument to _getSidebarItems,
-        see the docstring of _getSidebarItems on how it uses it.
-
-      rights: The rights dictionary is used to check if the user has
-        the required rights to see a sidebar item.
-        See checkAccess for more details on how the rights dictionary
-        is used to check access rights.
-      sidebar_heading: The sidebar_heading value is used to set the
-        heading variable in the result.
-      name: The name value is used if sidebar_heading is not present.
-
-    Returns: A dictionary is returned with it's 'heading' value set
-      as explained above. It's 'items' value is constructed by
-      calling _getSidebarItems. It constists of dictionaries with a
-      url and a title field.
+      The params dictionary is passed as argument to getSidebarItems
+        from the soc.views.sitemap.sidebar module, see the docstring
+        of _getSidebarItems on how it uses it.
     """
 
     params = dicts.merge(params, self._params)
-    rights = params['rights']
-
-    items = []
-
-    for url, menu_text, access_type in self._getSidebarItems(params):
-      try:
-        access.checkAccess(access_type, request, rights)
-        items.append({'url': url, 'title': menu_text})
-      except out_of_band.Error:
-        pass
-
-    if not items:
-      return
-
-    res = {}
-
-    if 'sidebar_heading' not in params:
-      params['sidebar_heading'] = params['name']
-
-    res['heading'] = params['sidebar_heading']
-    res['items'] = items
-
-    return res
+    return sitemap.sidebar.getSidebarLinks(params)
 
   def getDjangoURLPatterns(self, params=None):
-    """Retrieves a list of sidebar entries for this view from self._params.
-
-    If self._params['django_patterns'] is None default entries will be
-    constructed.
+    """Retrieves a list of sidebar entries for this view
 
     Params usage:
-      The params dictionary is passed to the getKeyFieldsPatterns
-        method, see it's docstring on how it is used.
-      django_patterns: The django_patterns value is returned directly
-        if it is non-False.
-      django_patterns_defaults: The dajngo_patterns_defaults value is
-        used to construct the url patterns. It is expected to be a
-        list of tuples. The tuples should contain an url, a module
-        name, and the name of the url. The name is used as the
-        page_name passed as keyword argument, but also as the name
-        by which the url is known to Django internally.
-      url_name: The url_name argument is passed as argument to each
-        url, together with the link_id pattern, the link_id core
-        pattern, and the key fields for this View.
+      The params dictionary is passed to the getDjangoURLPatterns
+        function in the soc.views.sitemap.sitemap module, see the
+        docstring of getDjangoURLPatterns on how it uses it.
 
     Args:
       params: a dict with params for this View