99from ietf .idtracker .models import IETFWG , InternetDraft , Rfc
1010from ietf .ipr .models import IprRfc , IprDraft , IprDetail
1111from ietf .ipr .related import related_docs
12- from ietf .utils import log
12+ from ietf .utils import log , draft_search
1313
1414
1515def mark_last_doc (iprs ):
@@ -80,20 +80,15 @@ def search(request, type="", q="", id=""):
8080 # Search by RFC number or draft-identifier
8181 # Document list with IPRs
8282 if type in ["document_search" , "rfc_search" ]:
83+ doc = q
8384 if type == "document_search" :
8485 if q :
85- # normalize the draft name.
86- q = q .strip ()
87- q = re .sub ("\.txt$" ,"" ,q )
88- q = re .sub ("-\d\d$" ,"" ,q )
89- start = InternetDraft .objects .filter (filename__contains = q )
86+ start = draft_search (q )
9087 if id :
9188 start = InternetDraft .objects .filter (id_document_tag = id )
92- doc = q
9389 if type == "rfc_search" :
9490 if q :
9591 start = Rfc .objects .filter (rfc_number = q )
96- doc = "RFC%04d" % int (q )
9792 if start .count () == 1 :
9893 first = start [0 ]
9994 doc = str (first )
@@ -102,10 +97,10 @@ def search(request, type="", q="", id=""):
10297 docs = related_docs (first , [])
10398 #docs = get_doclist.get_doclist(first)
10499 iprs , docs = iprs_from_docs (docs )
105- return render ("ipr/search_doc_result.html" , {"q" : q , "first" : first , "docs" : docs , "doc" : doc },
100+ return render ("ipr/search_doc_result.html" , {"q" : q , "first" : first , "iprs" : iprs , " docs" : docs , "doc" : doc },
106101 context_instance = RequestContext (request ) )
107102 elif start .count ():
108- return render ("ipr/search_doc_list.html" , {"q" : q , "docs" : start , "doc" : doc },
103+ return render ("ipr/search_doc_list.html" , {"q" : q , "docs" : start },
109104 context_instance = RequestContext (request ) )
110105 else :
111106 return render ("ipr/search_doc_result.html" , {"q" : q , "first" : {}, "iprs" : {}, "docs" : {}, "doc" : doc },
0 commit comments