added some test charts
This commit is contained in:
@@ -102,9 +102,11 @@ class SujetListView(ListView):
|
|||||||
|
|
||||||
|
|
||||||
def info_completed_filter(qs):
|
def info_completed_filter(qs):
|
||||||
|
COMPLETED_RATIO = 70 # % of total fields completed
|
||||||
|
|
||||||
excluded_set = set()
|
excluded_set = set()
|
||||||
for sujet in qs:
|
for sujet in qs:
|
||||||
if sujet.statistiques.info_completed >= 50:
|
if sujet.statistiques.info_completed >= COMPLETED_RATIO:
|
||||||
excluded_set.add(sujet.pk)
|
excluded_set.add(sujet.pk)
|
||||||
|
|
||||||
return qs.exclude(pk__in=excluded_set)
|
return qs.exclude(pk__in=excluded_set)
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ LOGIN_URL = 'index'
|
|||||||
if DEBUG:
|
if DEBUG:
|
||||||
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
|
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
|
||||||
else: #TODO: configure a real backend
|
else: #TODO: configure a real backend
|
||||||
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
|
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
|
||||||
|
|
||||||
AUTHENTICATION_BACKENDS = [
|
AUTHENTICATION_BACKENDS = [
|
||||||
'utilisateurs.backends.CustomUserAuthentication'
|
'utilisateurs.backends.CustomUserAuthentication'
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
{% block breadcrumbs %}
|
{% block breadcrumbs %}
|
||||||
{{ block.super }}
|
{{ block.super }}
|
||||||
<li>Maraudes</li>
|
<li>Tests</li>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block page_content %}
|
{% block page_content %}
|
||||||
|
|||||||
25
statistiques/templates/statistiques/test.html
Normal file
25
statistiques/templates/statistiques/test.html
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
{% extends "statistiques/base.html" %}
|
||||||
|
{% load static %}
|
||||||
|
|
||||||
|
{% block title %}{{ block.super }} Maraudes{% endblock %}
|
||||||
|
|
||||||
|
|
||||||
|
{% block sidebar %}
|
||||||
|
{{ block.super }}
|
||||||
|
<div class="panel panel-primary">
|
||||||
|
<div class="panel-body text-right">
|
||||||
|
{% include "statistiques/filter_form.html" %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block breadcrumbs %}
|
||||||
|
{{ block.super }}
|
||||||
|
<li>Tests</li>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block page_content %}
|
||||||
|
{{ par_heure.as_html }}
|
||||||
|
<hr />
|
||||||
|
{{ par_heure_continu.as_html }}
|
||||||
|
{% endblock %}
|
||||||
@@ -7,5 +7,6 @@ urlpatterns = [
|
|||||||
url('^charts/$', views.PieChartView.as_view(), name="pies"),
|
url('^charts/$', views.PieChartView.as_view(), name="pies"),
|
||||||
url(r'^details/(?P<pk>[0-9]+)/$', views.StatistiquesDetailsView.as_view(), name="details"),
|
url(r'^details/(?P<pk>[0-9]+)/$', views.StatistiquesDetailsView.as_view(), name="details"),
|
||||||
url(r'^update/(?P<pk>[0-9]+)/$', views.StatistiquesUpdateView.as_view(), name="update"),
|
url(r'^update/(?P<pk>[0-9]+)/$', views.StatistiquesUpdateView.as_view(), name="update"),
|
||||||
|
url(r'^tests/$', views.TestStatsView.as_view(), name="tests"),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
@@ -175,6 +175,60 @@ class PieChartView(FilterMixin, generic.TemplateView):
|
|||||||
return context
|
return context
|
||||||
|
|
||||||
|
|
||||||
|
import collections
|
||||||
|
|
||||||
|
|
||||||
|
def get_data_table(observations, continuous=False):
|
||||||
|
return_zero = lambda: 0
|
||||||
|
data_table = collections.defaultdict(return_zero)
|
||||||
|
|
||||||
|
for o in observations:
|
||||||
|
heure_debut = datetime.datetime.strptime("%s" % o.rencontre.heure_debut, "%H:%M:%S")
|
||||||
|
if continuous:
|
||||||
|
heure_fin = heure_debut + datetime.timedelta(0, o.rencontre.duree * 60)
|
||||||
|
else:
|
||||||
|
heure_fin = heure_debut
|
||||||
|
|
||||||
|
for heure in range(heure_debut.hour, heure_fin.hour + 1):
|
||||||
|
data_table[heure] += 1
|
||||||
|
|
||||||
|
return data_table
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class TestStatsView(FilterMixin, generic.TemplateView):
|
||||||
|
template_name = "statistiques/test.html"
|
||||||
|
|
||||||
|
def get_context_data(self, **kwargs):
|
||||||
|
context = super().get_context_data(**kwargs)
|
||||||
|
|
||||||
|
observations = self.get_observations_queryset()
|
||||||
|
|
||||||
|
par_heure = get_data_table(observations)
|
||||||
|
context['par_heure'] = gchart.LineChart(
|
||||||
|
SimpleDataSource(
|
||||||
|
[("Heure", "Nbr de rencontres")] +
|
||||||
|
[(heure, par_heure[heure]) for heure in sorted(par_heure.keys())]
|
||||||
|
),
|
||||||
|
options = {
|
||||||
|
"title": "Nombre de rencontres par heure (démarrée)"
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
en_continu = get_data_table(observations, continuous=True)
|
||||||
|
context['par_heure_continu'] = gchart.LineChart(
|
||||||
|
SimpleDataSource(
|
||||||
|
[("Heure", "Nbr de rencontres")] +
|
||||||
|
[(heure, en_continu[heure]) for heure in sorted(en_continu.keys())]
|
||||||
|
),
|
||||||
|
options = {
|
||||||
|
"title": "Nombre de rencontres par heure (en cumulé)"
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
return context
|
||||||
|
|
||||||
|
|
||||||
# AjaxMixin
|
# AjaxMixin
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user