recherche: première ébauche
[auf_framonde.git] / project / aldryn_search / router.py
CommitLineData
5f23ec55
PH
1# -*- coding: utf-8 -*-
2from django.conf import settings
3from django.utils.translation import get_language
4
5from haystack import routers
6from haystack.constants import DEFAULT_ALIAS
7
8
9class 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