mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
pep8 fixes
This commit is contained in:
committed by
Jeremy Stretch
parent
eed1b8f412
commit
18ea7d1e13
@ -1,7 +1,8 @@
|
||||
from django.db.models import TextField
|
||||
|
||||
|
||||
class CachedValueField(TextField):
|
||||
"""
|
||||
Currently a dummy field to prevent custom lookups being applied globally to TextField.
|
||||
"""
|
||||
pass
|
||||
pass
|
||||
|
@ -1,6 +1,7 @@
|
||||
from django.db.models import CharField, TextField, Lookup
|
||||
from .fields import CachedValueField
|
||||
|
||||
|
||||
class Empty(Lookup):
|
||||
"""
|
||||
Filter on whether a string is empty.
|
||||
@ -26,5 +27,6 @@ class NetContainsOrEquals(Lookup):
|
||||
params = lhs_params + rhs_params
|
||||
return 'CAST(%s as inet) >>= %s' % (lhs, rhs), params
|
||||
|
||||
|
||||
CharField.register_lookup(Empty)
|
||||
CachedValueField.register_lookup(NetContainsOrEquals)
|
||||
|
@ -108,7 +108,7 @@ class CachedValueSearchBackend(SearchBackend):
|
||||
if lookup == LookupTypes.PARTIAL:
|
||||
try:
|
||||
address = str(netaddr.IPNetwork(value.strip()).cidr)
|
||||
query_filter |= Q(type=FieldTypes.CIDR) & Q(value__net_contains_or_equals=address)
|
||||
query_filter |= Q(type=FieldTypes.CIDR) & Q(value__net_contains_or_equals=address)
|
||||
except (AddrFormatError, ValueError):
|
||||
pass
|
||||
|
||||
|
Reference in New Issue
Block a user