app/soc/views/simple.py
changeset 270 7dd6d8347b56
parent 141 e120c24b89e2
child 272 00cea07656c0
equal deleted inserted replaced
269:0f1acc4c3e1e 270:7dd6d8347b56
    25 
    25 
    26 from django.utils.translation import ugettext_lazy
    26 from django.utils.translation import ugettext_lazy
    27 
    27 
    28 from soc.logic import out_of_band
    28 from soc.logic import out_of_band
    29 from soc.logic.site import id_user
    29 from soc.logic.site import id_user
       
    30 from soc.views import helper
       
    31 import soc.views.helper.templates
    30 from soc.views.helpers import response_helpers
    32 from soc.views.helpers import response_helpers
    31 from soc.views.helpers import template_helpers
       
    32 
    33 
    33 
    34 
    34 def templateWithLinkName(request,
    35 def templateWithLinkName(request,
    35                          template='soc/base.html', linkname=None,
    36                          template='soc/base.html', linkname=None,
    36                          context=None):
    37                          context=None):
    72   Returns:
    73   Returns:
    73     A subclass of django.http.HttpResponse containing the generated page.
    74     A subclass of django.http.HttpResponse containing the generated page.
    74   """
    75   """
    75   return templateWithLinkName(
    76   return templateWithLinkName(
    76       request, linkname=linkname, context=context,
    77       request, linkname=linkname, context=context,
    77       template=template_helpers.makeSiblingTemplatesList(
    78       template=helper.templates.makeSiblingTemplatesList(
    78           template, 'public.html'))
    79           template, 'public.html'))
    79 
    80 
    80 
    81 
    81 DEF_ERROR_TMPL = 'soc/error.html'
    82 DEF_ERROR_TMPL = 'soc/error.html'
    82 
    83 
    95         was not supplied to the ErrorResponse
    96         was not supplied to the ErrorResponse
    96   """
    97   """
    97   context = response_helpers.getUniversalContext(request, context=context)
    98   context = response_helpers.getUniversalContext(request, context=context)
    98   
    99   
    99   # make a list of possible "sibling" templates, then append a default
   100   # make a list of possible "sibling" templates, then append a default
   100   error_templates = template_helpers.makeSiblingTemplatesList(
   101   error_templates = helper.templates.makeSiblingTemplatesList(
   101       template, 'error.html', default_template=DEF_ERROR_TMPL)
   102       template, 'error.html', default_template=DEF_ERROR_TMPL)
   102 
   103 
   103   context['error_status'] = error.response_args.get('status')
   104   context['error_status'] = error.response_args.get('status')
   104   context['error_message'] = error.message
   105   context['error_message'] = error.message
   105 
   106 
   128         to the login template in lieu of using login_message_fmt
   129         to the login template in lieu of using login_message_fmt
   129   """
   130   """
   130   context = response_helpers.getUniversalContext(request, context=context)
   131   context = response_helpers.getUniversalContext(request, context=context)
   131   
   132   
   132   # make a list of possible "sibling" templates, then append a default
   133   # make a list of possible "sibling" templates, then append a default
   133   login_templates = template_helpers.makeSiblingTemplatesList(
   134   login_templates = helper.templates.makeSiblingTemplatesList(
   134       template, 'login.html', default_template=DEF_LOGIN_TMPL)
   135       template, 'login.html', default_template=DEF_LOGIN_TMPL)
   135   
   136   
   136   if not context.get('login_message'):
   137   if not context.get('login_message'):
   137     if not login_message_fmt:
   138     if not login_message_fmt:
   138       login_message_fmt = DEF_LOGIN_MSG_FMT
   139       login_message_fmt = DEF_LOGIN_MSG_FMT