Add statistics page
This commit is contained in:
+24
-1
@@ -8,7 +8,7 @@ from django.http import HttpResponse, HttpResponseRedirect
|
||||
from django.contrib.auth.decorators import permission_required, login_required
|
||||
from django.conf import settings
|
||||
import logging
|
||||
from webapp.models import CustomKaehmyRole
|
||||
from webapp.models import PresetKaehmyRole, CustomKaehmyRole
|
||||
from webapp.models import OhlhafvChallenge, KaehmyForm
|
||||
from webapp.forms import OhlhafvForm, KaehmyForm_Form, KaehmyCommentForm
|
||||
from webapp.tables import OhlhafvTable
|
||||
@@ -206,3 +206,26 @@ def kaehmy_comment(request, *args, **kwargs):
|
||||
'errors': form.errors
|
||||
}
|
||||
return render(request, 'error.html', context)
|
||||
|
||||
|
||||
@require_http_methods(["GET"])
|
||||
def kaehmy_statistics_view(request, *args, **kwargs):
|
||||
"""Kaehmys roles listed by applications"""
|
||||
|
||||
applications = KaehmyForm.objects.all()
|
||||
role_list = []
|
||||
|
||||
preset_roles = PresetKaehmyRole.objects.all()
|
||||
custom_roles = CustomKaehmyRole.objects.all()
|
||||
|
||||
for preset in preset_roles:
|
||||
role_list.append((preset.name, preset.forms.all().count()))
|
||||
for custom in custom_roles:
|
||||
role_list.append((custom.name, custom.forms.all().count()))
|
||||
|
||||
context = {
|
||||
'applications': applications,
|
||||
'application_count': len(applications),
|
||||
'role_list': role_list
|
||||
}
|
||||
return render(request, 'kaehmy_statistics.html', context)
|
||||
|
||||
Reference in New Issue
Block a user