cleans up code of 'statistiques' module

This commit is contained in:
artus40
2018-03-09 15:28:31 +01:00
parent 2f9b987d1f
commit 8ae1c677f6
4 changed files with 10 additions and 19 deletions

View File

@@ -32,13 +32,6 @@ LABELS = {
}
# TODO: Retrieve charts data from cache to avoid recalculating on each request
class CachedDataSource:
pass
# TODO: Clean up...
class FieldValuesCountDataSource(SimpleDataSource):
""" Generates data from a limited set of choices.
@@ -192,7 +185,6 @@ class AgePieChart(PieWrapper):
super().__init__(data=data, title="Âge")
class IndividuGroupeChart(PieWrapper):
def __init__(self, queryset):
@@ -257,7 +249,6 @@ class RencontreParMoisChart(ColumnWrapper):
)
def gen_heure_minute(_from, to):
start_hour = _from.hour
stop_hour, stop_min = to.hour, to.minute
@@ -335,4 +326,4 @@ class RencontreParLieuChart(PieWrapper):
if self.queryset:
data += [(label, self.get_count_for_group(lieu_pks)) for label, lieu_pks in self.labels]
super().__init__(data=data,
title="Fréquentation par lieu")
title="Fréquentation par lieu")

View File

@@ -1,10 +1,9 @@
from django import forms
from django.db.utils import OperationalError
from .models import FicheStatistique
class StatistiquesForm(forms.ModelForm):
class StatistiquesForm(forms.ModelForm):
class Meta:
model = FicheStatistique
exclude = ["sujet"]
@@ -16,8 +15,10 @@ def get_year_range():
).order_by(
'sujet__premiere_rencontre'
)
year = lambda f: f.sujet.premiere_rencontre.year
def year(fiche):
return fiche.sujet.premiere_rencontre.year
# Need to call exists() in a try block
# to avoid raising exception on first migration
try:
@@ -30,6 +31,6 @@ def get_year_range():
else:
return ()
class SelectRangeForm(forms.Form):
class SelectRangeForm(forms.Form):
period = forms.ChoiceField(label="Année", choices=[(0, 'Tout')] + [(i, str(i)) for i in get_year_range()])

View File

@@ -92,7 +92,6 @@ class FicheStatistique(models.Model):
verbose_name = "Fiche statistique"
class GroupeLieux(models.Model):
label = models.CharField(max_length=128, primary_key=True)
lieux = models.ManyToManyField("maraudes.Lieu")
@@ -103,4 +102,3 @@ class GroupeLieux(models.Model):
class Meta:
verbose_name = "Groupe de lieux"
verbose_name_plural = "Groupes de lieux"

View File

@@ -160,7 +160,7 @@ class ComparatifHeures(MultipleChartsView):
])
def get_queryset(self):
#return self.get_observations_queryset()
# Return self.get_observations_queryset()
debut_essai = datetime.datetime(2017, 11, 23)
# Horaires démarrés le 23novembre 2017, calcul de la période effective d'application
@@ -178,8 +178,9 @@ class ComparatifHeures(MultipleChartsView):
print(debut_periode, fin_periode)
return Observation.objects.filter(created_date__range=(debut_periode, fin_periode))
# AjaxMixin
class AjaxOrRedirectMixin(object):
class AjaxOrRedirectMixin:
""" For view that should be retrieved by Ajax only. If not,
redirects to the primary view where these are displayed """