8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-12-26 08:53:46 +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:
klafyvel 2018-10-14 23:35:58 +02:00
commit 3b11d351a7

View file

@ -27,6 +27,8 @@ Gplv2"""
from __future__ import unicode_literals
from netaddr import EUI, AddrFormatError
from django.shortcuts import render
from django.contrib.auth.decorators import login_required
@ -171,6 +173,11 @@ def search_single_word(word, filters, user,
) | Q(
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]:
filter_machines &= Q(user__id=user.id)
filters['machines'] |= filter_machines