app/soc/logic/site/sidebar.py
changeset 481 94834a1e6c01
parent 477 8a8b1bd035c4
equal deleted inserted replaced
480:9b07ddeb1412 481:94834a1e6c01
    23   ]
    23   ]
    24 
    24 
    25 
    25 
    26 from google.appengine.api import users
    26 from google.appengine.api import users
    27 
    27 
       
    28 from soc.logic import accounts
    28 from soc.logic import menu
    29 from soc.logic import menu
    29 from soc.logic.site import id_user
       
    30 from soc.logic.site import map
    30 from soc.logic.site import map
    31 
    31 
    32 
    32 
    33 def buildUserSidebar(id=None, **ignored):
    33 def buildUserSidebar(account=None, **ignored):
    34   """Returns a list of menu items for the User portion of the sidebar.
    34   """Returns a list of menu items for the User portion of the sidebar.
    35   
    35   
    36   Args:
    36   Args:
    37     id: a Google Account (users.User) object; default is None, in which
    37     account: a Google Account (users.User) object; default is None, in which
    38       case users.get_current_user() is called 
    38       case users.get_current_user() is called 
    39     **ignored: other keyword arguments supplied to other sidebar builder
    39     **ignored: other keyword arguments supplied to other sidebar builder
    40       functions, but ignored by this one
    40       functions, but ignored by this one
    41   """
    41   """
    42   if id is None:
    42   if account is None:
    43     id = users.get_current_user()
    43     account = users.get_current_user()
    44 
    44 
    45   if not id:
    45   if not account:
    46     return [map.user_signin_sub_menu.makeMenuItem()]
    46     return [map.user_signin_sub_menu.makeMenuItem()]
    47 
    47 
    48   return [map.user_signout_sub_menu.makeMenuItem()]
    48   return [map.user_signout_sub_menu.makeMenuItem()]
    49 
    49 
    50 
    50 
    52   """Returns a list of menu items for the Developer portion of the sidebar.
    52   """Returns a list of menu items for the Developer portion of the sidebar.
    53   
    53   
    54   Args:
    54   Args:
    55     is_admin: Boolean indicating that current user is a "Developer"
    55     is_admin: Boolean indicating that current user is a "Developer"
    56       (site super-user); default is None, in which case
    56       (site super-user); default is None, in which case
    57       id_user.isIdDeveloper() is called 
    57       accounts.isDeveloper() is called 
    58     **ignored: other keyword arguments supplied to other sidebar builder
    58     **ignored: other keyword arguments supplied to other sidebar builder
    59       functions, but ignored by this one
    59       functions, but ignored by this one
    60   """
    60   """
    61   if is_admin is None:
    61   if is_admin is None:
    62     is_admin = id_user.isIdDeveloper()
    62     is_admin = accounts.isDeveloper()
    63 
    63 
    64   if not is_admin:
    64   if not is_admin:
    65     # user is either not logged in or not a "Developer", so return no menu
    65     # user is either not logged in or not a "Developer", so return no menu
    66     return None
    66     return None
    67 
    67