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

@@ -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()])