Add statistics page
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% load bootstrap3 %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block navigation %}
|
||||
{% include "kaehmy_navigation.html" %}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div>
|
||||
<h3>{% trans "Statistics" %}</h3>
|
||||
<div>
|
||||
<h2>{% trans "All kaehmys" %}</h2>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h6>{% trans "Total kaehmys:" %} {{ application_count }}</h6>
|
||||
</div>
|
||||
|
||||
{% for role in role_list %}
|
||||
<div>
|
||||
<p>{{ role.0 }} ({{ role.1 }})</p>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endblock content %}
|
||||
@@ -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),
|
||||
|
||||
+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