Set null on user delete.
[wolnelektury.git] / src / wolnelektury / abtests.py
1 import hashlib
2 from django.conf import settings
3
4
5 def context_processor(request):
6     ab = {}
7     overrides = getattr(settings, 'AB_TESTS_OVERRIDES', {})
8     for abtest, nvalues in settings.AB_TESTS.items():
9         ab[abtest] = overrides.get(
10             abtest,
11             hashlib.md5(
12                 (abtest + request.META['REMOTE_ADDR']).encode('utf-8')
13             ).digest()[0] % nvalues
14         )
15     return {'AB': ab}