Add support for registering of statistics functions instead of statics app importing from other apps
This commit is contained in:
@@ -0,0 +1,5 @@
|
|||||||
|
statistics_functions = []
|
||||||
|
|
||||||
|
|
||||||
|
def register_statistics(function):
|
||||||
|
statistics_functions.append(function)
|
||||||
@@ -4,15 +4,12 @@ from django.shortcuts import render_to_response
|
|||||||
from django.template import RequestContext
|
from django.template import RequestContext
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
from documents.statistics import get_statistics as documents_statistics
|
from .api import statistics_functions
|
||||||
from ocr.statistics import get_statistics as ocr_statistics
|
|
||||||
|
|
||||||
|
|
||||||
def statistics_view(request):
|
def statistics_view(request):
|
||||||
if request.user.is_superuser or request.user.is_staff:
|
if request.user.is_superuser or request.user.is_staff:
|
||||||
blocks = []
|
blocks = [function() for function in statistics_functions]
|
||||||
blocks.append(documents_statistics())
|
|
||||||
blocks.append(ocr_statistics())
|
|
||||||
|
|
||||||
return render_to_response('statistics.html', {
|
return render_to_response('statistics.html', {
|
||||||
'blocks': blocks,
|
'blocks': blocks,
|
||||||
|
|||||||
Reference in New Issue
Block a user