Commit 23c493ec authored by Gabriel Detraz's avatar Gabriel Detraz Committed by Admin Y Strator

Bug fix

parent 2ca28c7b
...@@ -473,12 +473,12 @@ def index(request): ...@@ -473,12 +473,12 @@ def index(request):
user_ens = len(User.objects.filter(state=0).filter(is_ens=True)) user_ens = len(User.objects.filter(state=0).filter(is_ens=True))
solde_moyen = round(solde_total/user_total, 2) solde_moyen = round(solde_total/user_total, 2)
commandes_total = len(Commande.objects.all()) commandes_total = len(Commande.objects.all())
try: next_livraison = Livraison.objects.order_by('date').filter(date__gt=timezone.now()).first()
next_livraison = Livraison.objects.order_by('date').filter(date__gt=timezone.now())[0] next_livraison_commandes = 0
except IndexError: next_livraison_paniers = 0
next_livraison = None if next_livraison:
next_livraison_commandes = len(Commande.objects.filter(date=Livraison.objects.filter(date=next_livraison.date))) next_livraison_commandes = Commande.objects.filter(date=Livraison.objects.filter(date=next_livraison.date)).count()
next_livraison_paniers = sum(pan.coefficient_panier*pan.quantite for pan in Commande.objects.filter(date=Livraison.objects.filter(date=next_livraison.date))) next_livraison_paniers = sum(pan.coefficient_panier*pan.quantite for pan in Commande.objects.filter(date=Livraison.objects.filter(date=next_livraison.date)))
return render(request, 'panier/index.html', {'paniers_list': paniers_list, 'management_view': management_view, 'credit_list': credit_list, 'solde_total': solde_total, 'user_total': user_total, 'user_ens': user_ens, 'solde_moyen': solde_moyen, 'commandes_total': commandes_total, 'next_livraison': next_livraison, 'next_livraison_commandes': next_livraison_commandes, 'next_livraison_paniers': next_livraison_paniers}) return render(request, 'panier/index.html', {'paniers_list': paniers_list, 'management_view': management_view, 'credit_list': credit_list, 'solde_total': solde_total, 'user_total': user_total, 'user_ens': user_ens, 'solde_moyen': solde_moyen, 'commandes_total': commandes_total, 'next_livraison': next_livraison, 'next_livraison_commandes': next_livraison_commandes, 'next_livraison_paniers': next_livraison_paniers})
@login_required @login_required
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment