Commits

Kai Diefenbach committed d69545c

Added LANGUAGES_DICT and LFC_LANGUAGE_IDS to lfc.settings.py

Comments (0)

Files changed (3)

lfc/context_processors.py

+# django imports
+from django.conf import settings
+from django.utils import translation
+
 # lfc imports
 import lfc.utils
-from django.conf import settings
-from django.utils import translation
+from lfc.settings import LANGUAGES_DICT
 
 def main(request):
     """context processor for LFC.
         "LFC_MANAGE_APPLICATIONS" : settings.LFC_MANAGE_APPLICATIONS,
         "LFC_MANAGE_USERS" : settings.LFC_MANAGE_USERS,
         "LFC_MANAGE_PERMISSIONS" : settings.LFC_MANAGE_PERMISSIONS,
-        "LANGUAGES_DICT" : settings.LANGUAGES_DICT,
+        "LANGUAGES_DICT" : LANGUAGES_DICT,
         "DEFAULT_LANGUAGE" : default_language,
         "CURRENT_LANGUAGE" : current_language,
         "IS_DEFAULT_LANGUAGE" : is_default_language,
 LANGUAGE_CHOICES = [("0", _(u"Neutral"),)]
 LANGUAGE_CHOICES.extend(settings.LANGUAGES)
 
+LANGUAGES_DICT = []
+for language in settings.LANGUAGES:
+    LANGUAGES_DICT.append({
+        "code" : language[0],
+        "name" : language[1],
+    })
+
+LFC_LANGUAGE_IDS = [l[0] for l in settings.LANGUAGES]
+
 COPY = 1
 CUT = 2

lfc/utils/middleware.py

 from django.conf import settings
 from django.http import Http404
 from django.http import HttpResponseServerError
-from django.shortcuts import get_object_or_404
 from django.utils import translation
 
 # lfc imports
+from lfc.settings import LFC_LANGUAGE_IDS
 from lfc.utils import traverse_object
 from lfc.utils import get_portal
 from lfc.utils import get_content_object
 
-from lfc.models import BaseContent
-
 class ProfileMiddleware(object):
     """
     Displays hotshot profiling for any view.
         if language:
             # if settings.LFC_MULTILANGUAGE == False:
             #     raise Http404
-            if language not in settings.LFC_LANGUAGE_IDS:
+            if language not in LFC_LANGUAGE_IDS:
                 raise Http404
 
             translation.activate(language)