app/soc/views/helper/responses.py
changeset 481 94834a1e6c01
parent 448 075360be6743
child 493 6976c4d8d0ac
equal deleted inserted replaced
480:9b07ddeb1412 481:94834a1e6c01
    26 from google.appengine.api import users
    26 from google.appengine.api import users
    27 
    27 
    28 from django import http
    28 from django import http
    29 from django.template import loader
    29 from django.template import loader
    30 
    30 
       
    31 from soc.logic import accounts
    31 from soc.logic import system
    32 from soc.logic import system
    32 from soc.logic.models import site_settings
    33 from soc.logic.models import site_settings
    33 from soc.logic.site import id_user
       
    34 from soc.logic.site import sidebar
    34 from soc.logic.site import sidebar
    35 from soc.views import helper
    35 from soc.views import helper
    36 from soc.views.helper import html_menu
    36 from soc.views.helper import html_menu
    37 
    37 
    38 import soc.logic
    38 import soc.logic
    79   Returns:
    79   Returns:
    80     a new context dict containing:
    80     a new context dict containing:
    81     
    81     
    82     {
    82     {
    83       'request': the Django HTTP request object passed in by the caller
    83       'request': the Django HTTP request object passed in by the caller
    84       'id': the logged-in Google Account if there is one
    84       'account': the logged-in Google Account if there is one
    85       'user': the User entity corresponding to the Google Account in
    85       'user': the User entity corresponding to the Google Account in
    86         context['id']
    86         context['account']
    87       'is_admin': True if users.is_current_user_admin() is True
    87       'is_admin': True if users.is_current_user_admin() is True
    88       'is_debug': True if system.isDebug() is True
    88       'is_debug': True if system.isDebug() is True
    89       'sign_in': a Google Account login URL
    89       'sign_in': a Google Account login URL
    90       'sign_out': a Google Account logout URL
    90       'sign_out': a Google Account logout URL
    91       'sidebar_menu_html': an HTML string that renders the sidebar menu
    91       'sidebar_menu_html': an HTML string that renders the sidebar menu
    92     }
    92     }
    93   """
    93   """
    94 
    94 
    95   id = users.get_current_user()
    95   account = users.get_current_user()
    96 
    96 
    97   context = {}
    97   context = {}
    98   context['request'] = request
    98   context['request'] = request
    99 
    99 
   100   if id:
   100   if account:
   101     context['id'] = id
   101     context['account'] = account
   102     context['user'] = soc.logic.models.user.logic.getForFields(
   102     context['user'] = soc.logic.models.user.logic.getForFields(
   103         {'id': id}, unique=True)
   103         {'account': account}, unique=True)
   104     context['is_admin'] = id_user.isIdDeveloper(id=id)
   104     context['is_admin'] = accounts.isDeveloper(account=account)
   105 
   105 
   106   context['is_debug'] = system.isDebug()
   106   context['is_debug'] = system.isDebug()
   107   context['sign_in'] = users.create_login_url(request.path)
   107   context['sign_in'] = users.create_login_url(request.path)
   108   context['sign_out'] = users.create_logout_url(request.path)
   108   context['sign_out'] = users.create_logout_url(request.path)
   109   context['sidebar_menu_html'] = str(html_menu.UlMenu(
   109   context['sidebar_menu_html'] = str(html_menu.UlMenu(