X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/8f6f6d2cc234f08e48055a1804997f6773321b3e..10dc1a5e84d23582a58ead2551ddf54a66b94496:/src/stats/utils.py diff --git a/src/stats/utils.py b/src/stats/utils.py index fc473a6f0..86ce54ccd 100644 --- a/src/stats/utils.py +++ b/src/stats/utils.py @@ -62,3 +62,16 @@ def piwik_track(klass_or_method): return klass else: return wrap + + +def piwik_track_view(view): + if not getattr(settings, 'PIWIK_SITE_ID', 0): + return view + + def wrap(request, *args, **kwargs): + if getattr(request, 'piwik_track', True): + track_request.delay(piwik_url(request)) + return view(request, *args, **kwargs) + + update_wrapper(wrap, view) + return wrap