diff --git a/avisstage/views_search.py b/avisstage/views_search.py index 2c62d6b..b77c0de 100644 --- a/avisstage/views_search.py +++ b/avisstage/views_search.py @@ -147,11 +147,11 @@ def cherche(**kwargs): # Dates if field_relevant("avant_annee", False): - dte = date(kwargs["avant_annee"] + 1, 1, 1) + dte = date(min(2100, kwargs["avant_annee"]) + 1, 1, 1) filtres &= Q(date_fin__lt=dte) if field_relevant("apres_annee", False): - dte = date(kwargs["apres_annee"], 1, 1) + dte = date(max(2000, kwargs["apres_annee"]), 1, 1) filtres &= Q(date_debut__gte=dte) # Type de stage @@ -187,6 +187,8 @@ def cherche(**kwargs): ) else: resultat = resultat.order_by(tri) + else: + resultat = resultat.order_by(tri) return resultat, tri