|
|
@ -3,6 +3,7 @@ from django.db.models import Q |
|
|
from django.shortcuts import render |
|
|
from django.shortcuts import render |
|
|
from django.utils.html import escape |
|
|
from django.utils.html import escape |
|
|
from abonapp.models import Abon |
|
|
from abonapp.models import Abon |
|
|
|
|
|
from mydefs import ip_addr_regex |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def replace_without_case(orig, old, new): |
|
|
def replace_without_case(orig, old, new): |
|
|
@ -13,8 +14,12 @@ def home(request): |
|
|
s = request.GET.get('s') |
|
|
s = request.GET.get('s') |
|
|
|
|
|
|
|
|
if s: |
|
|
if s: |
|
|
query = Q(fio__icontains=s) | Q(username__icontains=s) | Q(telephone__icontains=s) | Q(ip_address=s) |
|
|
|
|
|
abons = Abon.objects.filter(query) |
|
|
|
|
|
|
|
|
if bool(re.match(ip_addr_regex, s)): |
|
|
|
|
|
abons = Abon.objects.filter(ip_address=s) |
|
|
|
|
|
else: |
|
|
|
|
|
abons = Abon.objects.filter( |
|
|
|
|
|
Q(fio__icontains=s) | Q(username__icontains=s) | Q(telephone__icontains=s) |
|
|
|
|
|
) |
|
|
else: |
|
|
else: |
|
|
abons = [] |
|
|
abons = [] |
|
|
|
|
|
|
|
|
|