src/cm/context_processors.py
changeset 0 40c8f766c9b8
child 160 0c01050f9717
equal deleted inserted replaced
-1:000000000000 0:40c8f766c9b8
       
     1 from django.conf import settings
       
     2 from cm.models import ApplicationConfiguration
       
     3 
       
     4 def static(request):
       
     5     """
       
     6     add static data to be used in templates
       
     7     """
       
     8     return {
       
     9             'SITE_URL' : settings.SITE_URL,
       
    10             'CLIENT_DEBUG' : settings.CLIENT_DEBUG,
       
    11             'YUI_VERSION' : settings.YUI_VERSION,
       
    12             'CONF': ApplicationConfiguration
       
    13             }
       
    14 
       
    15 
       
    16 
       
    17 def tz(request):
       
    18     """
       
    19     Add tz info
       
    20     """
       
    21     return {
       
    22         # TODO: set tz to user timezone if logged in
       
    23         'tz': request.session.get('tz',None),
       
    24         'tz_installed' : True,
       
    25     }
       
    26     
       
    27 
       
    28 from cm.utils.i18n import translate_to
       
    29 LOCAL_LANGUAGES = []
       
    30 for code, value in settings.LANGUAGES:
       
    31     trans_value = translate_to(value, code)
       
    32     LOCAL_LANGUAGES.append((code, trans_value))
       
    33 
       
    34 def utils(request):
       
    35     """
       
    36     all utils objects:
       
    37     - 'intelligent' language object
       
    38     """
       
    39     return {
       
    40             'LOCAL_LANGUAGES' : LOCAL_LANGUAGES,
       
    41             }