Skip to content

Commit d28bf58

Browse files
committed
Refactoring out draft_search(), and tweaking the IPR doc result template.
- Legacy-Id: 782
1 parent 941c984 commit d28bf58

4 files changed

Lines changed: 21 additions & 11 deletions

File tree

ietf/ipr/search.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from ietf.idtracker.models import IETFWG, InternetDraft, Rfc
1010
from ietf.ipr.models import IprRfc, IprDraft, IprDetail
1111
from ietf.ipr.related import related_docs
12-
from ietf.utils import log
12+
from ietf.utils import log, draft_search
1313

1414

1515
def 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 },

ietf/templates/ipr/search_doc_result.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
{% if not iprs %}
88
<tr>
99
<td></td>
10-
<td colspan="2"><b>{% block search_failed %}No IPR disclosures were found related to <i>{{ doc }}</i> have been submitted{% endblock %}</b></td>
10+
<td colspan="2"><b>{% block search_failed %}No IPR disclosures were found related to <i>{{ doc }}</i>{% endblock %}</b></td>
1111
</tr>
1212
{% else %}
1313
<tr><td colspan="3">Total number of IPR disclosures found: {{ iprs|length }} </td></tr>

ietf/utils/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from cache_foreign_key import FKAsOneToOne
66
from templated_form import makeTemplatedForm
77
from soup2text import TextSoup, soup2text
8+
from draft_search import draft_search
89

910
makeFormattingForm = makeTemplatedForm
1011

ietf/utils/draft_search.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Copyright The IETF Trust 2007, All Rights Reserved
2+
import re
3+
from ietf.idtracker.models import InternetDraft
4+
5+
def draft_search(s):
6+
drafts = []
7+
if s:
8+
# normalize the draft name.
9+
s = s.strip()
10+
s = re.sub("\.txt$","",s)
11+
s = re.sub("-\d\d$","",s)
12+
drafts = InternetDraft.objects.filter(filename__contains=s)
13+
return drafts
14+

0 commit comments

Comments
 (0)