recherche: première ébauche
[auf_framonde.git] / project / aldryn_search / router.py
1 # -*- coding: utf-8 -*-
2 from django.conf import settings
3 from django.utils.translation import get_language
4
5 from haystack import routers
6 from haystack.constants import DEFAULT_ALIAS
7
8
9 class LanguageRouter(routers.BaseRouter):
10
11 def for_read(self, **hints):
12 language = get_language()
13 if language not in settings.HAYSTACK_CONNECTIONS:
14 return DEFAULT_ALIAS
15 return language
16
17 def for_write(self, **hints):
18 language = get_language()
19 if language not in settings.HAYSTACK_CONNECTIONS:
20 return DEFAULT_ALIAS
21 return language