Commit a182a383 authored by Gabriel Detraz's avatar Gabriel Detraz Committed by Amap

Limite l'affichage en recherche

parent e5b08093
......@@ -9,7 +9,7 @@ https://docs.djangoproject.com/en/1.8/ref/settings/
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
from .settings_local import SECRET_KEY, DATABASES, DEBUG, ALLOWED_HOSTS, ASSO_NAME, ASSO_ADDRESS_LINE1, ASSO_ADDRESS_LINE2, ASSO_SIRET, ASSO_EMAIL, ASSO_PHONE, LOGO_PATH, services_urls, REQ_EXPIRE_HRS, REQ_EXPIRE_STR, EMAIL_FROM, MINIMUM_LEVEL, EMAIL_HOST, SITE_NAME
from .settings_local import SECRET_KEY, DATABASES, DEBUG, ALLOWED_HOSTS, ASSO_NAME, ASSO_ADDRESS_LINE1, ASSO_ADDRESS_LINE2, ASSO_SIRET, ASSO_EMAIL, ASSO_PHONE, LOGO_PATH, services_urls, REQ_EXPIRE_HRS, REQ_EXPIRE_STR, EMAIL_FROM, MINIMUM_LEVEL, EMAIL_HOST, SEARCH_RESULT, SITE_NAME
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
......
......@@ -22,6 +22,7 @@
{% if not users_list and not article_list and not livraison_list and not credit_list and not paniers_list%}
<h3>Aucun résultat</h3>
{% endif %}
<h6>(Seulement les {{ max_result }} premiers résultats sont affichés dans chaque catégorie)</h6>
<br />
<br />
<br />
......
......@@ -14,6 +14,8 @@ from users.models import User
from search.models import SearchForm, SearchFormPlus
from panier.models import Commande, Panier, Credit, Livraison
from nephaliste.settings import SEARCH_RESULT
def form(ctx, template, request):
c = ctx
c.update(csrf(request))
......@@ -54,23 +56,23 @@ def search_result(search, type, request):
for i in aff:
if i == '0':
users = User.objects.filter((Q(pseudo__icontains = search) | Q(name__icontains = search) | Q(surname__icontains = search)) & query)
users = User.objects.filter((Q(pseudo__icontains = search) | Q(name__icontains = search) | Q(surname__icontains = search)) & query)[:SEARCH_RESULT]
query = Q(user__pseudo__icontains = search) | Q(user__name__icontains = search) | Q(user__surname__icontains = search)
if not request.user.has_perms(('bureau',)):
users = [request.user]
if i == '1':
panier = Panier.objects.filter(nom__icontains = search)
panier = Panier.objects.filter(nom__icontains = search)[:SEARCH_RESULT]
if i == '2':
commande = Commande.objects.filter(Q(date=Livraison.objects.filter(date_query)) & query)
if not request.user.has_perms(('bureau',)):
commande = commande.filter(user=request.user)
commande = commande.filter(user=request.user)[:SEARCH_RESULT]
if i == '3':
livraison = Livraison.objects.filter(date_query)
livraison = Livraison.objects.filter(date_query)[:SEARCH_RESULT]
if i == '4':
credit = Credit.objects.filter(query)
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}
return {'users_list': users, 'article_list' : panier, 'paniers_list' : commande, 'livraison_list' : livraison, '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