diff --git a/statistiques/charts.py b/statistiques/charts.py index 4025283..2a557ff 100644 --- a/statistiques/charts.py +++ b/statistiques/charts.py @@ -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") \ No newline at end of file + title="Fréquentation par lieu") diff --git a/statistiques/forms.py b/statistiques/forms.py index 9fe2fc1..01d7584 100644 --- a/statistiques/forms.py +++ b/statistiques/forms.py @@ -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()]) diff --git a/statistiques/models.py b/statistiques/models.py index 289fb5c..e5f923c 100644 --- a/statistiques/models.py +++ b/statistiques/models.py @@ -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" - diff --git a/statistiques/views.py b/statistiques/views.py index 9e68d67..e20a79b 100644 --- a/statistiques/views.py +++ b/statistiques/views.py @@ -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 """