mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-30 08:32:26 +00:00
Merge branch 'fix_179' into 'dev'
Fix #179 : permet la recherche qqsoit le format de macaddr See merge request federez/re2o!337
This commit is contained in:
commit
3b11d351a7
1 changed files with 7 additions and 0 deletions
|
@ -27,6 +27,8 @@ Gplv2"""
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from netaddr import EUI, AddrFormatError
|
||||||
|
|
||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
from django.contrib.auth.decorators import login_required
|
from django.contrib.auth.decorators import login_required
|
||||||
|
|
||||||
|
@ -171,6 +173,11 @@ def search_single_word(word, filters, user,
|
||||||
) | Q(
|
) | Q(
|
||||||
interface__ipv4__ipv4__icontains=word
|
interface__ipv4__ipv4__icontains=word
|
||||||
)
|
)
|
||||||
|
try:
|
||||||
|
_mac_addr = EUI(word)
|
||||||
|
filter_machines |= Q(interface__mac_address=word)
|
||||||
|
except AddrFormatError:
|
||||||
|
pass
|
||||||
if not Machine.can_view_all(user)[0]:
|
if not Machine.can_view_all(user)[0]:
|
||||||
filter_machines &= Q(user__id=user.id)
|
filter_machines &= Q(user__id=user.id)
|
||||||
filters['machines'] |= filter_machines
|
filters['machines'] |= filter_machines
|
||||||
|
|
Loading…
Reference in a new issue