Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
re2o
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nounous
re2o
Commits
69340e6c
Commit
69340e6c
authored
Oct 12, 2016
by
root
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Le nombre d'objet afiché est une variable
parent
19e33b55
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
11 deletions
+13
-11
.gitignore
.gitignore
+1
-1
re2o/settings.py
re2o/settings.py
+1
-1
search/templates/search/index.html
search/templates/search/index.html
+1
-1
search/views.py
search/views.py
+10
-8
No files found.
.gitignore
View file @
69340e6c
settings_local.py
*.swp
*.pyc
__pycache__
__pycache__
/*
static_files/*
re2o/settings.py
View file @
69340e6c
...
...
@@ -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__
)))
...
...
search/templates/search/index.html
View file @
69340e6c
...
...
@@ -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
/>
...
...
search/views.py
View file @
69340e6c
...
...
@@ -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
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment