src/cm/context_processors.py
author Simon Descarpentries <sid@sopinspace.com>
Wed, 09 May 2012 17:13:33 +0200
changeset 417 c5e91f204371
parent 228 3a0f8b54a151
child 444 9246b0057a75
permissions -rw-r--r--
After investigations, commit the proposed patch by kklimonda presented with the following introduction : cm/templates/site/login_form.html template uses a relative url for the form action, which seems to break deployment in the subfolder when trailing slash is missing (the form redirects to the upper folder breaking login). Using {% url login %} (as in the attached patch) instead would fix the issue.

from django.conf import settings
from cm.models import ApplicationConfiguration
from cm.cm_settings import TRACKING_HTML
def static(request):
    """
    add static data to be used in templates
    """
    return {
            'SITE_URL' : settings.SITE_URL,
            'CLIENT_DEBUG' : settings.CLIENT_DEBUG,
            'YUI_VERSION' : settings.YUI_VERSION,
            'CONF': ApplicationConfiguration,
            'CM_MEDIA_PREFIX' : settings.CM_MEDIA_PREFIX,
            'TRACKING_HTML' : TRACKING_HTML,
            }



def tz(request):
    """
    Add tz info
    """
    return {
        # TODO: set tz to user timezone if logged in
        'tz': request.session.get('tz',None),
        'tz_installed' : True,
    }
    

from cm.utils.i18n import translate_to
LOCAL_LANGUAGES = []
for code, value in settings.LANGUAGES:
    trans_value = translate_to(value, code)
    LOCAL_LANGUAGES.append((code, trans_value))

def utils(request):
    """
    all utils objects:
    - 'intelligent' language object
    """
    return {
            'LOCAL_LANGUAGES' : LOCAL_LANGUAGES,
            }