Commit afad34a8 authored by Gabriel Detraz's avatar Gabriel Detraz Committed by root

Fix bug recherche

parent 1de735a9
......@@ -12,10 +12,6 @@
<h2>Résultats dans les paniers en vente : </h2>
{% include "panier/aff_article.html" with article_list=article_list %}
{% endif %}
{% if livraison_list %}
<h2>Résultats dans les livraisons : </h2>
{% include "panier/aff_livraison.html" with livraison_list=livraison_list %}
{% endif %}
{% if credit_list or paniers_list %}
{% include "panier/aff_paniers.html" %}
{% endif %}
......
......@@ -36,7 +36,7 @@ def search_result(search, type, request):
date_livraison = search.cleaned_data['date_livraison']
date_query = Q()
if aff==[]:
aff = ['0','1','2','3','4','5','6']
aff = ['0','1','2','3']
if date_deb != None:
date_query = date_query & Q(date__gte=date_deb)
if date_fin != None:
......@@ -52,7 +52,6 @@ def search_result(search, type, request):
commande = None
panier = None
credit = None
livraison = None
for i in aff:
if i == '0':
......@@ -63,16 +62,14 @@ def search_result(search, type, request):
if i == '1':
panier = Panier.objects.filter(nom__icontains = search)[:SEARCH_RESULT]
if i == '2':
commande = Commande.objects.filter(Q(date=Livraison.objects.filter(date_query)) & query)[:SEARCH_RESULT]
commande = Commande.objects.filter(Q(date__in=Livraison.objects.filter(date_query)) & query)[:SEARCH_RESULT]
if not request.user.has_perms(('bureau',)):
commande = commande.filter(user=request.user)[:SEARCH_RESULT]
if i == '3':
livraison = Livraison.objects.filter(date_query)[:SEARCH_RESULT]
if i == '4':
credit = Credit.objects.filter(query)[:SEARCH_RESULT]
if not request.user.has_perms(('bureau',)):
credit = credit.filter(user=request.user)
return {'users_list': users, 'article_list' : panier, 'paniers_list' : commande, 'livraison_list' : livraison, 'credit_list' : credit , 'max_result' : SEARCH_RESULT}
return {'users_list': users, 'article_list' : panier, 'paniers_list' : commande, 'credit_list' : credit , 'max_result' : SEARCH_RESULT}
@login_required
def search(request):
......
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