Skip to content

Commit

Permalink
Fix for #175. The code didn't handle the case of no match on a draft …
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
levkowetz committed Jun 29, 2007
1 parent 8b950ae commit 3647077
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 36 deletions.
7 changes: 6 additions & 1 deletion ietf/ipr/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ def search(request, type="", q="", id=""):
if type in ["document_search", "rfc_search"]:
if type == "document_search":
if q:
# normalize the draft name.
q = q.strip()
q = re.sub("\.txt$","",q)
q = re.sub("-\d\d$","",q)
start = InternetDraft.objects.filter(filename__contains=q)
if id:
start = InternetDraft.objects.filter(id_document_tag=id)
Expand All @@ -101,7 +105,8 @@ def search(request, type="", q="", id=""):
return render("ipr/search_doc_list.html", {"q": q, "docs": start },
context_instance=RequestContext(request) )
else:
raise ValueError("Missing or malformed search parameters, or internal error")
return render("ipr/search_doc_result.html", {"q": q, "first": {}, "iprs": {}, "docs": {}},
context_instance=RequestContext(request) )

# Search by legal name
# IPR list with documents
Expand Down
77 changes: 42 additions & 35 deletions ietf/templates/ipr/search_doc_result.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,49 @@
{% extends "ipr/search_result.html" %}
{% load ietf_filters %}
{% block search_result %}
<table cellpadding="1" cellspacing="0" border="0">
<table cellpadding="1" cellspacing="0" border="0">

<tr><td colspan="3">Total number of IPR disclosures found: {{ iprs|length }} </td></tr>
{% for ipr in iprs|dictsort:"submitted_date" %}
<tr valign="top" bgcolor="#dadada">
<td width="100">{{ ipr.submitted_date }}</td>
<td width="90"><li>ID # {{ ipr.ipr_id }}</li></td>
<td><a href="{% url ietf.ipr.views.show ipr_id=ipr.ipr_id %}">"{{ ipr.title }}"</a></td>
</tr>
{% endfor %}
{% if not iprs %}
<tr>
<td></td>
<td colspan="2"><b>{% block search_failed %}No IPR disclosures were found relating to <i>{{ q }}</i>{% endblock %}</b></td>
</tr>
{% else %}
<tr><td colspan="3">Total number of IPR disclosures found: {{ iprs|length }} </td></tr>
{% for ipr in iprs|dictsort:"submitted_date" %}
<tr valign="top" bgcolor="#dadada">
<td width="100">{{ ipr.submitted_date }}</td>
<td width="90"><li>ID # {{ ipr.ipr_id }}</li></td>
<td><a href="{% url ietf.ipr.views.show ipr_id=ipr.ipr_id %}">"{{ ipr.title }}"</a></td>
</tr>
{% endfor %}

<tr><td colspan="3"><hr>Total number of documents searched: {{ docs|length}}</td></tr>
{% for doc in docs %}
<tbody bgcolor="#{% cycle dadada,eaeaea as bgcolor %}">
<tr >
<td colspan="3">
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 %}
{% endifnotequal %}
</td>
</tr>
{% if doc.iprs %}
{% for ipr in doc.iprs %}
<tr valign="top">
<td width="100">{{ ipr.submitted_date }}</td>
<td width="90"><li>ID # {{ ipr.ipr_id }}</li></td>
<td><a href="{% url ietf.ipr.views.show %}{{ ipr.ipr_id }}">"{{ ipr.title }}"</a></td>
</tr>
{% endfor %}
{% else %}
<tr>
<td></td>
<td colspan="2"><b>No IPR disclosures related to <i>{{ doc|rfcspace|lstrip:"0" }}</i> have been submitted</b></td>
</tr>
{% endif %}
</tbody>
{% endfor %}
<tr><td colspan="3"><hr>Total number of documents searched: {{ docs|length}}</td></tr>
{% for doc in docs %}
<tbody bgcolor="#{% cycle dadada,eaeaea as bgcolor %}">
<tr >
<td colspan="3">
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 %}
{% endifnotequal %}
</td>
</tr>
{% if doc.iprs %}
{% for ipr in doc.iprs %}
<tr valign="top">
<td width="100">{{ ipr.submitted_date }}</td>
<td width="90"><li>ID # {{ ipr.ipr_id }}</li></td>
<td><a href="{% url ietf.ipr.views.show %}{{ ipr.ipr_id }}">"{{ ipr.title }}"</a></td>
</tr>
{% endfor %}
{% else %}
<tr>
<td></td>
<td colspan="2"><b>No IPR disclosures related to <i>{{ doc|rfcspace|lstrip:"0" }}</i> have been submitted</b></td>
</tr>
{% endif %}
</tbody>
{% endfor %}
{% endif %}

</table>
</table>
{% endblock %}

0 comments on commit 3647077

Please sign in to comment.