diff --git a/webapp/templates/kaehmy_statistics.html b/webapp/templates/kaehmy_statistics.html
new file mode 100644
index 0000000..c5e1eb8
--- /dev/null
+++ b/webapp/templates/kaehmy_statistics.html
@@ -0,0 +1,27 @@
+{% extends "base.html" %}
+
+{% load bootstrap3 %}
+{% load i18n %}
+
+{% block navigation %}
+ {% include "kaehmy_navigation.html" %}
+{% endblock %}
+
+{% block content %}
+
+
{% trans "Statistics" %}
+
+
{% trans "All kaehmys" %}
+
+
+
+
{% trans "Total kaehmys:" %} {{ application_count }}
+
+
+ {% for role in role_list %}
+
+
{{ role.0 }} ({{ role.1 }})
+
+ {% endfor %}
+
+{% endblock content %}
diff --git a/webapp/urls.py b/webapp/urls.py
index f93c35c..372decb 100644
--- a/webapp/urls.py
+++ b/webapp/urls.py
@@ -22,6 +22,7 @@ from webapp.views import kaehmy_view
from webapp.views import kaehmy_list_view
from webapp.views import kaehmy_submit
from webapp.views import kaehmy_comment
+from webapp.views import kaehmy_statistics_view
urlpatterns = [
# main
@@ -51,6 +52,7 @@ urlpatterns = [
url(r'^kaehmy/new', kaehmy_view),
url(r'^kaehmy/submit', kaehmy_submit),
url(r'^kaehmy/add_comment', kaehmy_comment),
+ url(r'^kaehmy/statistics', kaehmy_statistics_view),
# ohlhafv
url(r'^ohlhafv$', ohlhafv_view),
diff --git a/webapp/views.py b/webapp/views.py
index d26fe0f..df5e9aa 100644
--- a/webapp/views.py
+++ b/webapp/views.py
@@ -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)