Another minimal refactoring...
- Legacy-Id: 784
This commit is contained in:
parent
ee50e92759
commit
79124036a3
|
@ -9,7 +9,7 @@ from django.conf import settings
|
|||
from ietf.idtracker.models import IETFWG, InternetDraft, Rfc
|
||||
from ietf.ipr.models import IprRfc, IprDraft, IprDetail
|
||||
from ietf.ipr.related import related_docs
|
||||
from ietf.utils import log, draft_search
|
||||
from ietf.utils import log, normalize_draftname
|
||||
|
||||
|
||||
def mark_last_doc(iprs):
|
||||
|
@ -83,7 +83,8 @@ def search(request, type="", q="", id=""):
|
|||
doc = q
|
||||
if type == "document_search":
|
||||
if q:
|
||||
start = draft_search(q)
|
||||
q = normalize_draftname(q)
|
||||
start = InternetDraft.objects.filter(filename__contains=q)
|
||||
if id:
|
||||
start = InternetDraft.objects.filter(id_document_tag=id)
|
||||
if type == "rfc_search":
|
||||
|
|
|
@ -1,17 +1,9 @@
|
|||
# Copyright The IETF Trust 2007, All Rights Reserved
|
||||
import re
|
||||
from ietf.idtracker.models import InternetDraft
|
||||
|
||||
def normalize_draftname(string):
|
||||
string = string.strip()
|
||||
string = re.sub("\.txt$","",string)
|
||||
string = re.sub("-\d\d$","",string)
|
||||
return string
|
||||
|
||||
def draft_search(string):
|
||||
drafts = []
|
||||
if string:
|
||||
string = normalize_draftname(string)
|
||||
drafts = InternetDraft.objects.filter(filename__contains=string)
|
||||
return drafts
|
||||
|
Loading…
Reference in a new issue