Skip to content

Commit 6a2c3ab

Browse files
committed
Added IPR search by RFC number.
- Legacy-Id: 400
1 parent a746d90 commit 6a2c3ab

3 files changed

Lines changed: 46 additions & 30 deletions

File tree

ietf/ipr/testurl.list

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,6 @@
1010
200 /ipr/search/ https://datatracker.ietf.org/public/ipr_search.cgi
1111
302 /ipr/search/?option=document_search # incomplete argument set gives redirect
1212
200 /ipr/search/?option=document_search&document_search=mod https://datatracker.ietf.org/public/ipr_search.cgi?option=document_search&document_search=mod
13-
200 /ipr/search/?option=document_search&id_document_tag=2220 https://datatracker.ietf.org/public/ipr_search.cgi?option=document_search&id_document_tag=2220
13+
200,sort /ipr/search/?option=document_search&id_document_tag=2220 https://datatracker.ietf.org/public/ipr_search.cgi?option=document_search&id_document_tag=2220
14+
200,sort /ipr/search/?option=rfc_search&rfc_search=1034 https://datatracker.ietf.org/public/ipr_search.cgi?option=rfc_search&rfc_search=1034 # Loong result, RFC search
15+
200 /ipr/search/?option=rfc_search&rfc_search=4444 https://datatracker.ietf.org/public/ipr_search.cgi?option=rfc_search&rfc_search=4444 # Empty result, RFC search

ietf/ipr/views.py

Lines changed: 41 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def update(request, ipr_id=None):
9090
}
9191

9292
display_relation = {
93-
'updates': 'that updates',
93+
'updates': 'that updated',
9494
'is_updated_by': 'that was updated by',
9595
'obsoletes': 'that obsoleted',
9696
'is_obsoleted_by': 'that was obsoleted by',
@@ -101,7 +101,7 @@ def update(request, ipr_id=None):
101101
}
102102

103103
def set_related(obj, rel, target):
104-
print obj, rel, target
104+
#print obj, rel, target
105105
# remember only the first relationship we find.
106106
if not hasattr(obj, "related"):
107107
obj.related = target
@@ -112,7 +112,7 @@ def set_relation(first, rel, second):
112112
set_related(second, inverse[rel], first)
113113

114114
def related_docs(doc, found = []):
115-
print "\nrelated_docs(%s, %s)" % (doc, found)
115+
#print "\nrelated_docs(%s, %s)" % (doc, found)
116116
found.append(doc)
117117
if isinstance(doc, Rfc):
118118
try:
@@ -136,9 +136,9 @@ def related_docs(doc, found = []):
136136
found = related_docs(item, found)
137137
if isinstance(doc, InternetDraft):
138138
if doc.replaced_by_id:
139-
item = doc.replaced_by_id
139+
item = doc.replaced_by
140140
if not item in found:
141-
set_relation(doc, 'replaced_by', item)
141+
set_relation(doc, 'is_replaced_by', item)
142142
found = related_docs(item, found)
143143
for item in doc.replaces_set.all():
144144
if not item in found:
@@ -165,32 +165,46 @@ def search(request, type="", q="", id=""):
165165
if type and q or id:
166166
log("Got query: type=%s, q=%s, id=%s" % (type, q, id))
167167
if type == "document_search":
168-
log("Got document_search")
169168
if q:
170169
start = InternetDraft.objects.filter(filename__contains=q)
171-
log("Found %s drafts containing %s" % (start.count(), q))
172170
if id:
173171
start = InternetDraft.objects.filter(id_document_tag=id)
174-
log("Found %s drafts with id %s" % (start.count(), id))
175-
if start.count() == 1:
176-
first = start[0]
177-
# get all related drafts, then search for IPRs on all
178-
docs = related_docs(first, [])
179-
iprs = []
180-
for doc in docs:
181-
if isinstance(doc, InternetDraft):
182-
disclosures = [ item.ipr for item in IprDraft.objects.filter(document=doc) ]
183-
elif isinstance(doc, Rfc):
184-
disclosures = [ item.ipr for item in IprRfc.objects.filter(document=doc) ]
185-
else:
186-
raise ValueError("Neither draft nor rfc: %s" % doc)
187-
if disclosures:
188-
doc.iprs = disclosures
189-
iprs += disclosures
190-
iprs = list(set(iprs))
191-
return render("ipr/search_result.html", {"first": first, "iprs": iprs, "docs": docs})
192-
elif start.count():
193-
return render("ipr/search_list.html", {"docs": start })
172+
elif type == "rfc_search":
173+
if q:
174+
start = Rfc.objects.filter(rfc_number=q)
175+
elif type == "patent_search":
176+
pass
177+
elif type == "patent_info_search":
178+
pass
179+
elif type == "wg_search":
180+
pass
181+
elif type == "title_search":
182+
pass
183+
elif type == "ip_title_search":
184+
pass
185+
else:
186+
raise ValueError("Unexpected search type in IPR query: %s" % type)
187+
if start.count() == 1:
188+
first = start[0]
189+
# get all related drafts, then search for IPRs on all
190+
docs = related_docs(first, [])
191+
iprs = []
192+
for doc in docs:
193+
if isinstance(doc, InternetDraft):
194+
disclosures = [ item.ipr for item in IprDraft.objects.filter(document=doc) ]
195+
elif isinstance(doc, Rfc):
196+
disclosures = [ item.ipr for item in IprRfc.objects.filter(document=doc) ]
197+
else:
198+
raise ValueError("Doc type is neither draft nor rfc: %s" % doc)
199+
if disclosures:
200+
doc.iprs = disclosures
201+
iprs += disclosures
202+
iprs = list(set(iprs))
203+
return render("ipr/search_result.html", {"first": first, "iprs": iprs, "docs": docs})
204+
elif start.count():
205+
return render("ipr/search_list.html", {"docs": start })
206+
else:
207+
raise ValueError("Missing or malformed search parameters, or internal error")
194208
return django.http.HttpResponseRedirect(request.path)
195209
return render("ipr/search.html", {"wgs": wgs})
196210

ietf/templates/ipr/search_result.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ <h2>IPR Disclosures</h2></center>
2525
<tbody bgcolor="#{% cycle dadada,eaeaea as bgcolor %}">
2626
<tr >
2727
<td colspan="3">
28-
Search result on {{ doc }}, "{{ doc.title }}"{% ifnotequal doc first %}{% if doc.related %}, {{ doc.relation }} {{ doc.related }}, "{{ doc.related.title }}"{% endif %}
28+
Search result on {{ doc|rfcspace|lstrip:"0"|rfcnospace }}, "{{ doc.title }}"{% ifnotequal doc first %}{% if doc.related %}, {{ doc.relation }} {{ doc.related }}, "{{ doc.related.title }}"{% endif %}
2929
{% endifnotequal %}
3030
</td>
3131
</tr>
@@ -40,7 +40,7 @@ <h2>IPR Disclosures</h2></center>
4040
{% else %}
4141
<tr>
4242
<td></td>
43-
<td colspan="2"><b>No IPR disclosures related to <i>{{ doc|rfcspace }}</i> have been submitted</b></td>
43+
<td colspan="2"><b>No IPR disclosures related to <i>{{ doc|rfcspace|lstrip:"0" }}</i> have been submitted</b></td>
4444
</tr>
4545
{% endif %}
4646
</tbody>

0 commit comments

Comments
 (0)