Skip to content

Commit 3647077

Browse files
committed
Fix for adamlaska#175. The code didn't handle the case of no match on a draft name. (Neither did the legacy code!). Added display of 'no documents found' and also added code to strip '.txt' and draft version number if found, to facilitate the search.
- Legacy-Id: 754
1 parent 8b950ae commit 3647077

2 files changed

Lines changed: 48 additions & 36 deletions

File tree

ietf/ipr/search.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ def search(request, type="", q="", id=""):
8282
if type in ["document_search", "rfc_search"]:
8383
if type == "document_search":
8484
if q:
85+
# normalize the draft name.
86+
q = q.strip()
87+
q = re.sub("\.txt$","",q)
88+
q = re.sub("-\d\d$","",q)
8589
start = InternetDraft.objects.filter(filename__contains=q)
8690
if id:
8791
start = InternetDraft.objects.filter(id_document_tag=id)
@@ -101,7 +105,8 @@ def search(request, type="", q="", id=""):
101105
return render("ipr/search_doc_list.html", {"q": q, "docs": start },
102106
context_instance=RequestContext(request) )
103107
else:
104-
raise ValueError("Missing or malformed search parameters, or internal error")
108+
return render("ipr/search_doc_result.html", {"q": q, "first": {}, "iprs": {}, "docs": {}},
109+
context_instance=RequestContext(request) )
105110

106111
# Search by legal name
107112
# IPR list with documents

ietf/templates/ipr/search_doc_result.html

Lines changed: 42 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,42 +2,49 @@
22
{% extends "ipr/search_result.html" %}
33
{% load ietf_filters %}
44
{% block search_result %}
5-
<table cellpadding="1" cellspacing="0" border="0">
5+
<table cellpadding="1" cellspacing="0" border="0">
66

7-
<tr><td colspan="3">Total number of IPR disclosures found: {{ iprs|length }} </td></tr>
8-
{% for ipr in iprs|dictsort:"submitted_date" %}
9-
<tr valign="top" bgcolor="#dadada">
10-
<td width="100">{{ ipr.submitted_date }}</td>
11-
<td width="90"><li>ID # {{ ipr.ipr_id }}</li></td>
12-
<td><a href="{% url ietf.ipr.views.show ipr_id=ipr.ipr_id %}">"{{ ipr.title }}"</a></td>
13-
</tr>
14-
{% endfor %}
7+
{% if not iprs %}
8+
<tr>
9+
<td></td>
10+
<td colspan="2"><b>{% block search_failed %}No IPR disclosures were found relating to <i>{{ q }}</i>{% endblock %}</b></td>
11+
</tr>
12+
{% else %}
13+
<tr><td colspan="3">Total number of IPR disclosures found: {{ iprs|length }} </td></tr>
14+
{% for ipr in iprs|dictsort:"submitted_date" %}
15+
<tr valign="top" bgcolor="#dadada">
16+
<td width="100">{{ ipr.submitted_date }}</td>
17+
<td width="90"><li>ID # {{ ipr.ipr_id }}</li></td>
18+
<td><a href="{% url ietf.ipr.views.show ipr_id=ipr.ipr_id %}">"{{ ipr.title }}"</a></td>
19+
</tr>
20+
{% endfor %}
1521

16-
<tr><td colspan="3"><hr>Total number of documents searched: {{ docs|length}}</td></tr>
17-
{% for doc in docs %}
18-
<tbody bgcolor="#{% cycle dadada,eaeaea as bgcolor %}">
19-
<tr >
20-
<td colspan="3">
21-
Search result on {{ doc|rfcspace|lstrip:"0"|rfcnospace }}, "{{ doc.title }}"{% ifnotequal doc first %}{% if doc.related %}, {{ doc.relation }} {{ doc.related|rfcspace|lstrip:"0"|rfcnospace }}, "{{ doc.related.title }}"{% endif %}
22-
{% endifnotequal %}
23-
</td>
24-
</tr>
25-
{% if doc.iprs %}
26-
{% for ipr in doc.iprs %}
27-
<tr valign="top">
28-
<td width="100">{{ ipr.submitted_date }}</td>
29-
<td width="90"><li>ID # {{ ipr.ipr_id }}</li></td>
30-
<td><a href="{% url ietf.ipr.views.show %}{{ ipr.ipr_id }}">"{{ ipr.title }}"</a></td>
31-
</tr>
32-
{% endfor %}
33-
{% else %}
34-
<tr>
35-
<td></td>
36-
<td colspan="2"><b>No IPR disclosures related to <i>{{ doc|rfcspace|lstrip:"0" }}</i> have been submitted</b></td>
37-
</tr>
38-
{% endif %}
39-
</tbody>
40-
{% endfor %}
22+
<tr><td colspan="3"><hr>Total number of documents searched: {{ docs|length}}</td></tr>
23+
{% for doc in docs %}
24+
<tbody bgcolor="#{% cycle dadada,eaeaea as bgcolor %}">
25+
<tr >
26+
<td colspan="3">
27+
Search result on {{ doc|rfcspace|lstrip:"0"|rfcnospace }}, "{{ doc.title }}"{% ifnotequal doc first %}{% if doc.related %}, {{ doc.relation }} {{ doc.related|rfcspace|lstrip:"0"|rfcnospace }}, "{{ doc.related.title }}"{% endif %}
28+
{% endifnotequal %}
29+
</td>
30+
</tr>
31+
{% if doc.iprs %}
32+
{% for ipr in doc.iprs %}
33+
<tr valign="top">
34+
<td width="100">{{ ipr.submitted_date }}</td>
35+
<td width="90"><li>ID # {{ ipr.ipr_id }}</li></td>
36+
<td><a href="{% url ietf.ipr.views.show %}{{ ipr.ipr_id }}">"{{ ipr.title }}"</a></td>
37+
</tr>
38+
{% endfor %}
39+
{% else %}
40+
<tr>
41+
<td></td>
42+
<td colspan="2"><b>No IPR disclosures related to <i>{{ doc|rfcspace|lstrip:"0" }}</i> have been submitted</b></td>
43+
</tr>
44+
{% endif %}
45+
</tbody>
46+
{% endfor %}
47+
{% endif %}
4148

42-
</table>
49+
</table>
4350
{% endblock %}

0 commit comments

Comments
 (0)