Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
re2o
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nounous
re2o
Commits
79cf47e8
Commit
79cf47e8
authored
Jul 06, 2016
by
Dalahro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Recherche inclus switchs et ports
parent
917e983f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
4 deletions
+21
-4
search/models.py
search/models.py
+2
-0
search/templates/search/index.html
search/templates/search/index.html
+9
-1
search/views.py
search/views.py
+10
-3
No files found.
search/models.py
View file @
79cf47e8
...
...
@@ -20,6 +20,8 @@ CHOICES3 = (
(
'2'
,
'Factures'
),
(
'3'
,
'Bannissements'
),
(
'4'
,
'Accès à titre gracieux'
),
(
'6'
,
'Switchs'
),
(
'5'
,
'Ports'
),
)
...
...
search/templates/search/index.html
View file @
79cf47e8
...
...
@@ -24,7 +24,15 @@
<h2>
Résultats dans les banissements :
</h2>
{% include "users/aff_bans.html" with ban_list=ban_list %}
{% endif %}
{% if not ban_list and not machine_list and not users_list and not facture_list and not white_list%}
{% if switch_list %}
<h2>
Résultats dans les switchs :
</h2>
{% include "topologie/aff_switch.html" with switch_list=switch_list %}
{% endif %}
{% if port_list %}
<h2>
Résultats dans les ports :
</h2>
{% include "topologie/aff_port.html" with port_list=port_list %}
{% endif %}
{% if not ban_list and not machine_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 %}
<br
/>
...
...
search/views.py
View file @
79cf47e8
...
...
@@ -9,6 +9,7 @@ from django.template import Context, RequestContext, loader
from
django.db.models
import
Q
from
users.models
import
User
,
Ban
,
Whitelist
from
machines.models
import
Machine
,
Interface
from
topologie.models
import
Port
,
Switch
from
cotisations.models
import
Facture
from
search.models
import
SearchForm
,
SearchFormPlus
from
users.views
import
has_access
...
...
@@ -24,7 +25,7 @@ def search_result(search, type):
date_fin
=
None
states
=
[]
co
=
[]
aff
=
[
'0'
,
'1'
,
'2'
,
'3'
,
'4'
]
aff
=
[]
if
(
type
):
aff
=
search
.
cleaned_data
[
'affichage'
]
co
=
search
.
cleaned_data
[
'connexion'
]
...
...
@@ -33,7 +34,7 @@ def search_result(search, type):
date_fin
=
search
.
cleaned_data
[
'date_fin'
]
date_query
=
Q
()
if
aff
==
[]:
aff
=
[
'0'
,
'1'
,
'2'
,
'3'
,
'4'
]
aff
=
[
'0'
,
'1'
,
'2'
,
'3'
,
'4'
,
'5'
,
'6'
]
if
date_deb
!=
None
:
date_query
=
date_query
&
Q
(
date__gte
=
date_deb
)
if
date_fin
!=
None
:
...
...
@@ -48,6 +49,8 @@ def search_result(search, type):
factures
=
None
bans
=
None
whitelists
=
None
switchlist
=
None
portlist
=
None
connexion
=
[]
for
i
in
aff
:
...
...
@@ -71,7 +74,11 @@ def search_result(search, type):
bans
=
Ban
.
objects
.
filter
(
query
)
if
i
==
'4'
:
whitelists
=
Whitelist
.
objects
.
filter
(
query
)
return
{
'users_list'
:
connexion
,
'machine_list'
:
machines
,
'facture_list'
:
factures
,
'ban_list'
:
bans
,
'white_list'
:
whitelists
}
if
i
==
'5'
:
portlist
=
Port
.
objects
.
filter
(
details__icontains
=
search
)
if
i
==
'6'
:
switchlist
=
Switch
.
objects
.
filter
(
details__icontains
=
search
)
return
{
'users_list'
:
connexion
,
'machine_list'
:
machines
,
'facture_list'
:
factures
,
'ban_list'
:
bans
,
'white_list'
:
whitelists
,
'port_list'
:
portlist
,
'switch_list'
:
switchlist
}
def
search
(
request
):
if
request
.
method
==
'POST'
:
...
...
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