From 36470774d622f2dda37b185cd31bdbdcdadc4503 Mon Sep 17 00:00:00 2001 From: Henrik Levkowetz Date: Fri, 29 Jun 2007 11:22:15 +0000 Subject: [PATCH] Fix for #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 --- ietf/ipr/search.py | 7 ++- ietf/templates/ipr/search_doc_result.html | 77 ++++++++++++----------- 2 files changed, 48 insertions(+), 36 deletions(-) diff --git a/ietf/ipr/search.py b/ietf/ipr/search.py index 2bb346c2d4..833e5a031e 100644 --- a/ietf/ipr/search.py +++ b/ietf/ipr/search.py @@ -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) @@ -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 diff --git a/ietf/templates/ipr/search_doc_result.html b/ietf/templates/ipr/search_doc_result.html index 6ed92cd657..b0ff8c69e6 100644 --- a/ietf/templates/ipr/search_doc_result.html +++ b/ietf/templates/ipr/search_doc_result.html @@ -2,42 +2,49 @@ {% extends "ipr/search_result.html" %} {% load ietf_filters %} {% block search_result %} - +
- - {% for ipr in iprs|dictsort:"submitted_date" %} - - - - - - {% endfor %} + {% if not iprs %} + + + + + {% else %} + + {% for ipr in iprs|dictsort:"submitted_date" %} + + + + + + {% endfor %} - - {% for doc in docs %} - - - - - {% if doc.iprs %} - {% for ipr in doc.iprs %} - - - - - - {% endfor %} - {% else %} - - - - - {% endif %} - - {% endfor %} + + {% for doc in docs %} + + + + + {% if doc.iprs %} + {% for ipr in doc.iprs %} + + + + + + {% endfor %} + {% else %} + + + + + {% endif %} + + {% endfor %} + {% endif %} -
Total number of IPR disclosures found: {{ iprs|length }}
{{ ipr.submitted_date }}
  • ID # {{ ipr.ipr_id }}
  • "{{ ipr.title }}"
    {% block search_failed %}No IPR disclosures were found relating to {{ q }}{% endblock %}
    Total number of IPR disclosures found: {{ iprs|length }}
    {{ ipr.submitted_date }}
  • ID # {{ ipr.ipr_id }}
  • "{{ ipr.title }}"

    Total number of documents searched: {{ docs|length}}
    - 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 %} -
    {{ ipr.submitted_date }}
  • ID # {{ ipr.ipr_id }}
  • "{{ ipr.title }}"
    No IPR disclosures related to {{ doc|rfcspace|lstrip:"0" }} have been submitted

    Total number of documents searched: {{ docs|length}}
    + 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 %} +
    {{ ipr.submitted_date }}
  • ID # {{ ipr.ipr_id }}
  • "{{ ipr.title }}"
    No IPR disclosures related to {{ doc|rfcspace|lstrip:"0" }} have been submitted
    + {% endblock %}