8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-12-23 15:33:45 +00:00

Le nombre d'objet afiché est une variable

This commit is contained in:
root 2016-10-12 22:58:41 +02:00
parent 19e33b5520
commit 69340e6c33
4 changed files with 13 additions and 11 deletions

2
.gitignore vendored
View file

@ -1,5 +1,5 @@
settings_local.py
*.swp
*.pyc
__pycache__
__pycache__/*
static_files/*

View file

@ -12,7 +12,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, SITE_NAME, LDAP, MAIN_EXTENSION, GID_RANGES, UID_RANGES
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, SITE_NAME, LDAP, MAIN_EXTENSION, GID_RANGES, UID_RANGES, SEARCH_RESULT
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

View file

@ -35,7 +35,7 @@
{% if not ban_list and not interfaces_list and not users_list and not facture_list and not white_list and not port_list and not switch_list%}
<h3>Aucun résultat</h3>
{% endif %}
<h6>(Seulement les 15 premiers résultats sont affichés dans chaque catégorie)</h6>
<h6>(Seulement les {{ max_result }} premiers résultats sont affichés dans chaque catégorie)</h6>
<br />
<br />
<br />

View file

@ -14,6 +14,8 @@ from topologie.models import Port, Switch
from cotisations.models import Facture
from search.models import SearchForm, SearchFormPlus
from re2o.settings import SEARCH_RESULT
def form(ctx, template, request):
c = ctx
c.update(csrf(request))
@ -54,21 +56,21 @@ 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)[:15]
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 i == '1':
machines = Machine.objects.filter(query)[:15]
machines = Machine.objects.filter(query)[:SEARCH_RESULT]
if i == '2':
factures = Facture.objects.filter(query & date_query)[:15]
factures = Facture.objects.filter(query & date_query)[:SEARCH_RESULT]
if i == '3':
bans = Ban.objects.filter(query)[:15]
bans = Ban.objects.filter(query)[:SEARCH_RESULT]
if i == '4':
whitelists = Whitelist.objects.filter(query)[:15]
whitelists = Whitelist.objects.filter(query)[:SEARCH_RESULT]
if i == '5':
portlist = Port.objects.filter(details__icontains = search)[:15]
portlist = Port.objects.filter(details__icontains = search)[:SEARCH_RESULT]
if i == '6':
switchlist = Switch.objects.filter(details__icontains = search)[:15]
return {'users_list': users, 'machines_list' : machines, 'facture_list' : factures, 'ban_list' : bans, 'white_list': whitelists, 'port_list':portlist, 'switch_list':switchlist}
switchlist = Switch.objects.filter(details__icontains = search)[:SEARCH_RESULT]
return {'users_list': users, 'machines_list' : machines, 'facture_list' : factures, 'ban_list' : bans, 'white_list': whitelists, 'port_list':portlist, 'switch_list':switchlist, 'max_result' : SEARCH_RESULT}
@login_required
def search(request):