Skip to content

Commit 19da33d

Browse files
committed
Make the search for specific draft name in IPR support both drafts and RFCs, clean up some related cruft
- Legacy-Id: 6775
1 parent e9638cb commit 19da33d

5 files changed

Lines changed: 107 additions & 150 deletions

File tree

ietf/iesg/views.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -357,14 +357,6 @@ def agenda_documents(request):
357357
sections = agenda_sections()
358358
fill_in_agenda_docs(date, sections, docs_by_date[d])
359359

360-
for doc in docs_by_date[d]:
361-
if doc.type_id=='draft':
362-
if doc.get_state_slug() != "rfc":
363-
doc.iprUrl = "/ipr/search?option=document_search&id_document_tag=" + str(doc.name)
364-
else:
365-
doc.iprUrl = "/ipr/search?option=rfc_search&rfc_search=" + str(doc.rfc_number())
366-
doc.iprCount = len(doc.ipr())
367-
368360
telechats.append({
369361
"date":date,
370362
"sections": sorted((num, section) for num, section in sections.iteritems()

ietf/ipr/search.py

Lines changed: 27 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -39,46 +39,42 @@ def patent_file_search(url, q):
3939
return q in text
4040
return False
4141

42-
def search(request, type="", q="", id=""):
42+
def search(request):
4343
wgs = Group.objects.filter(type="wg").select_related().order_by("acronym")
44-
args = request.REQUEST.items()
45-
if args:
46-
for key, value in args:
47-
if key == "option":
48-
type = value
49-
if re.match(".*search", key):
44+
45+
search_type = request.GET.get("option")
46+
if search_type:
47+
docid = request.GET.get("id") or request.GET.get("id_document_tag") or ""
48+
49+
q = ""
50+
for key, value in request.GET.items():
51+
if key.endswith("search"):
5052
q = value
51-
if re.match(".*id", key):
52-
id = value
53-
if (type and q) or id:
54-
#log("Got query: type=%s, q=%s, id=%s" % (type, q, id))
5553

54+
if search_type and (q or docid):
5655
# Search by RFC number or draft-identifier
5756
# Document list with IPRs
58-
if type in ["document_search", "rfc_search"]:
57+
if search_type in ["document_search", "rfc_search"]:
5958
doc = q
60-
if type == "document_search":
61-
if q:
59+
60+
if docid:
61+
start = DocAlias.objects.filter(name=docid)
62+
else:
63+
if search_type == "document_search":
6264
q = normalize_draftname(q)
6365
start = DocAlias.objects.filter(name__contains=q, name__startswith="draft")
64-
if id:
65-
start = DocAlias.objects.filter(name=id)
66-
if type == "rfc_search":
67-
if q:
68-
try:
69-
q = int(q, 10)
70-
except:
71-
q = -1
72-
start = DocAlias.objects.filter(name__contains=q, name__startswith="rfc")
73-
if start.count() == 1:
66+
elif search_type == "rfc_search":
67+
start = DocAlias.objects.filter(name="rfc%s" % q.lstrip("0"))
68+
69+
if len(start) == 1:
7470
first = start[0]
7571
doc = str(first)
7672
docs = related_docs(first)
7773
iprs, docs = iprs_from_docs(docs)
7874
iprs.sort(key=lambda x: (x.submitted_date, x.ipr_id))
7975
return render("ipr/search_doc_result.html", {"q": q, "iprs": iprs, "docs": docs, "doc": doc },
8076
context_instance=RequestContext(request) )
81-
elif start.count():
77+
elif start:
8278
return render("ipr/search_doc_list.html", {"q": q, "docs": start },
8379
context_instance=RequestContext(request) )
8480
else:
@@ -87,7 +83,7 @@ def search(request, type="", q="", id=""):
8783

8884
# Search by legal name
8985
# IPR list with documents
90-
elif type == "patent_search":
86+
elif search_type == "patent_search":
9187
iprs = IprDetail.objects.filter(legal_name__icontains=q, status__in=[1,3]).order_by("-submitted_date", "-ipr_id")
9288
count = iprs.count()
9389
iprs = [ ipr for ipr in iprs if not ipr.updated_by.all() ]
@@ -96,7 +92,7 @@ def search(request, type="", q="", id=""):
9692

9793
# Search by content of email or pagent_info field
9894
# IPR list with documents
99-
elif type == "patent_info_search":
95+
elif search_type == "patent_info_search":
10096
if len(q) < 3:
10197
return render("ipr/search_error.html", {"q": q, "error": "The search string must contain at least three characters" },
10298
context_instance=RequestContext(request) )
@@ -119,7 +115,7 @@ def search(request, type="", q="", id=""):
119115

120116
# Search by wg acronym
121117
# Document list with IPRs
122-
elif type == "wg_search":
118+
elif search_type == "wg_search":
123119
docs = list(DocAlias.objects.filter(document__group__acronym=q))
124120
related = []
125121
for doc in docs:
@@ -136,7 +132,7 @@ def search(request, type="", q="", id=""):
136132

137133
# Search by rfc and id title
138134
# Document list with IPRs
139-
elif type == "title_search":
135+
elif search_type == "title_search":
140136
docs = list(DocAlias.objects.filter(document__title__icontains=q))
141137
related = []
142138
for doc in docs:
@@ -153,15 +149,15 @@ def search(request, type="", q="", id=""):
153149

154150
# Search by title of IPR disclosure
155151
# IPR list with documents
156-
elif type == "ipr_title_search":
152+
elif search_type == "ipr_title_search":
157153
iprs = IprDetail.objects.filter(title__icontains=q, status__in=[1,3]).order_by("-submitted_date", "-ipr_id")
158154
count = iprs.count()
159155
iprs = [ ipr for ipr in iprs if not ipr.updated_by.all() ]
160156
return render("ipr/search_iprtitle_result.html", {"q": q, "iprs": iprs, "count": count },
161157
context_instance=RequestContext(request) )
162158

163159
else:
164-
raise Http404("Unexpected search type in IPR query: %s" % type)
160+
raise Http404("Unexpected search type in IPR query: %s" % search_type)
165161
return HttpResponseRedirect(request.path)
166162

167163
return render("ipr/search.html", {"wgs": wgs}, context_instance=RequestContext(request))
Lines changed: 4 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,5 @@
1-
{% comment %}
2-
Copyright (C) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
3-
All rights reserved. Contact: Pasi Eronen <pasi.eronen@nokia.com>
4-
5-
Redistribution and use in source and binary forms, with or without
6-
modification, are permitted provided that the following conditions
7-
are met:
8-
9-
* Redistributions of source code must retain the above copyright
10-
notice, this list of conditions and the following disclaimer.
11-
12-
* Redistributions in binary form must reproduce the above
13-
copyright notice, this list of conditions and the following
14-
disclaimer in the documentation and/or other materials provided
15-
with the distribution.
16-
17-
* Neither the name of the Nokia Corporation and/or its
18-
subsidiary(-ies) nor the names of its contributors may be used
19-
to endorse or promote products derived from this software
20-
without specific prior written permission.
21-
22-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23-
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24-
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25-
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26-
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27-
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28-
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29-
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30-
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31-
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32-
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33-
{% endcomment %}
34-
{% load ietf_filters %}<td class="ipr">
35-
{% if doc.iprCount %}<a href="{{ doc.iprUrl }}" rel="nofollow"> IPR:{{ doc.iprCount }} </a>{% endif %}
1+
<td class="ipr">
2+
{% if doc.type_id == "draft" and doc.ipr %}
3+
<a href="{% url ipr_search %}?option=document_search&id={{ doc.canonical_name }}" rel="nofollow">IPR: {{ doc.ipr|length }}</a>
4+
{% endif %}
365
</td>

ietf/templates/ipr/search.html

Lines changed: 75 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -11,92 +11,92 @@
1111
<h1>IPR Search</h1>
1212
<h2>Document Search</h2>
1313
<div class="ietf-box search-form-box">
14-
<form>
15-
<input type="hidden" name="option" value="document_search">
14+
<form>
15+
<input type="hidden" name="option" value="document_search">
16+
<label>I-D name (draft-...):</label>
17+
<input type="text" name="document_search" size="30">
18+
<input type="submit" value="SEARCH" >
19+
</form>
1620

17-
<label>I-D name (draft-...):</label>
18-
<input type="text" name="document_search" size="30">
19-
<input type="submit" value="SEARCH" >
20-
</form>
21+
<script language="javascript"><!--
22+
function IsNumeric(strString) {
23+
var strValidChars = "0123456789.-";
24+
var strChar;
25+
var blnResult = true;
2126

22-
<script language="javascript"><!--
23-
function IsNumeric(strString) {
24-
var strValidChars = "0123456789.-";
25-
var strChar;
26-
var blnResult = true;
27+
if (strString.length == 0) return false;
2728

28-
if (strString.length == 0) return false;
29+
for (i = 0; i < strString.length && blnResult == true; i++)
30+
{
31+
strChar = strString.charAt(i);
32+
if (strValidChars.indexOf(strChar) == -1)
33+
{
34+
blnResult = false;
35+
}
36+
}
37+
return blnResult;
38+
}
2939

30-
for (i = 0; i < strString.length && blnResult == true; i++)
31-
{
32-
strChar = strString.charAt(i);
33-
if (strValidChars.indexOf(strChar) == -1)
34-
{
35-
blnResult = false;
36-
}
37-
}
38-
return blnResult;
39-
}
40-
41-
function check_numeric(val) {
42-
if (IsNumeric(val)) {
43-
return true;
44-
} else {
45-
alert ("Please enter numerics only");
46-
return false;
47-
}
48-
return false;
49-
}
50-
// -->
51-
</script>
52-
<form name="form_rfc_search">
53-
<input type="hidden" name="option" value="rfc_search">
54-
<label>RFC Number:</label>
55-
<input type="text" name="rfc_search" size="8">
56-
<input type="submit" value="SEARCH" onClick="return check_numeric(document.form_rfc_search.rfc_search.value);">
57-
</form>
40+
function check_numeric(val) {
41+
if (IsNumeric(val)) {
42+
return true;
43+
} else {
44+
alert ("Please enter numerics only");
45+
return false;
46+
}
47+
return false;
48+
}
49+
// -->
50+
</script>
51+
<form name="form_rfc_search">
52+
<input type="hidden" name="option" value="rfc_search">
53+
<label>RFC Number:</label>
54+
<input type="text" name="rfc_search" size="8">
55+
<input type="submit" value="SEARCH" onClick="return check_numeric(document.form_rfc_search.rfc_search.value);">
56+
</form>
5857
</div>
5958

6059
<h2>Keyword Search</h2>
6160

6261
<div class="ietf-box search_form_box">
6362

64-
<form>
65-
<input type="hidden" name="option" value="patent_search">
66-
<label>Name of patent owner/applicant:</label>
67-
<input type="text" name="patent_search" size="30">
68-
<input type="submit" value="SEARCH">
69-
</form>
70-
<form>
71-
<input type="hidden" name="option" value="patent_info_search"/>
72-
<label>Characters in patent information (Full/Partial):</label>
73-
<input type="text" name="patent_info_search" size="30"/>
74-
<input type="submit" value="SEARCH"/>
75-
</form>
76-
<font size="-1" color="red">* The search string must contain at least three characters, including at least one digit, and include punctuation marks. For best results, please enter the entire string, or as much of it as possible.</font>
63+
<form>
64+
<input type="hidden" name="option" value="patent_search">
65+
<label>Name of patent owner/applicant:</label>
66+
<input type="text" name="patent_search" size="30">
67+
<input type="submit" value="SEARCH">
68+
</form>
69+
<form>
70+
<input type="hidden" name="option" value="patent_info_search"/>
71+
<label>Characters in patent information (Full/Partial):</label>
72+
<input type="text" name="patent_info_search" size="30"/>
73+
<input type="submit" value="SEARCH"/>
74+
</form>
75+
76+
<font size="-1" color="red">* The search string must contain at least three characters, including at least one digit, and include punctuation marks. For best results, please enter the entire string, or as much of it as possible.</font>
7777

78-
<form>
79-
<input type="hidden" name="option" value="wg_search">
80-
<label>Working group name:</label>
81-
<select name="wg_search">
82-
<option value="">--Select WG</option>
83-
{% for wg in wgs %}
84-
<option value="{{ wg.acronym }}">{{ wg.acronym }}</option>{% endfor %}
85-
</select>
86-
<input type="submit" value="SEARCH" width="15">
87-
</form>
88-
<form>
89-
<input type="hidden" name="option" value="title_search"/>
90-
<label>Words in document title:</label>
91-
<input type="text" name="title_search" size="30" />
92-
<input type="submit" value="SEARCH" />
93-
</form>
94-
<form>
95-
<input type="hidden" name="option" value="ipr_title_search" />
96-
<label>Words in IPR disclosure title:</label>
97-
<input type="text" name="ipr_title_search" size="30" />
98-
<input type="submit" value="SEARCH" />
99-
</form>
78+
<form>
79+
<input type="hidden" name="option" value="wg_search">
80+
<label>Working group name:</label>
81+
<select name="wg_search">
82+
<option value="">--Select WG</option>
83+
{% for wg in wgs %}
84+
<option value="{{ wg.acronym }}">{{ wg.acronym }}</option>{% endfor %}
85+
</select>
86+
<input type="submit" value="SEARCH" width="15">
87+
</form>
88+
<form>
89+
<input type="hidden" name="option" value="title_search"/>
90+
<label>Words in document title:</label>
91+
<input type="text" name="title_search" size="30" />
92+
<input type="submit" value="SEARCH" />
93+
</form>
94+
<form>
95+
<input type="hidden" name="option" value="ipr_title_search" />
96+
<label>Words in IPR disclosure title:</label>
97+
<input type="text" name="ipr_title_search" size="30" />
98+
<input type="submit" value="SEARCH" />
99+
</form>
100100
</div>
101101

102102
<p><a href="{% url ietf.ipr.views.showlist %}">Back to IPR Disclosure Page</a></p>

ietf/templates/ipr/search_doc_list.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ <h1>IPR Disclosures - Select Internet-Draft</h1>
88
<h3>Please select one of following I-Ds</h3>
99
<ul>
1010
{% for docalias in docs %}
11-
<li><a href="?option=document_search&id_document_tag={{ docalias.document }}">{{ docalias.document }}</a></li>
11+
<li><a href="?option=document_search&id={{ docalias.name }}">{{ docalias.name }}</a></li>
1212
{% endfor %}
1313
</ul>
1414
{% endblock %}

0 commit comments

Comments
 (0)