Skip to content

Commit 9074e95

Browse files
committed
Additional IPR searches: WG search and holder (legal name) search.
- Legacy-Id: 644
1 parent d37b5bb commit 9074e95

4 files changed

Lines changed: 67 additions & 23 deletions

File tree

ietf/ipr/models.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,11 @@ class Admin:
149149

150150

151151
class IprDraft(models.Model):
152-
document = models.ForeignKey(InternetDraft, db_column='id_document_tag', raw_id_admin=True, core=True)
153152
ipr = models.ForeignKey(IprDetail, raw_id_admin=True, edit_inline=True, related_name='drafts')
153+
document = models.ForeignKey(InternetDraft, db_column='id_document_tag', raw_id_admin=True, core=True, related_name="ipr")
154154
revision = models.CharField(maxlength=2)
155155
def __str__(self):
156-
return "%s applies to %s-%s" % ( self.ipr, self.document, self.revision )
156+
return "%s which applies to %s-%s" % ( self.ipr, self.document, self.revision )
157157
class Meta:
158158
db_table = 'ipr_ids'
159159
class Admin:
@@ -173,9 +173,9 @@ class Admin:
173173

174174
class IprRfc(models.Model):
175175
ipr = models.ForeignKey(IprDetail, edit_inline=True, related_name='rfcs')
176-
document = models.ForeignKey(Rfc, db_column='rfc_number', raw_id_admin=True, core=True)
176+
document = models.ForeignKey(Rfc, db_column='rfc_number', raw_id_admin=True, core=True, related_name="ipr")
177177
def __str__(self):
178-
return "%s applies to RFC%04d" % ( self.ipr, self.rfc_number )
178+
return "%s applies to RFC%04d" % ( self.ipr, self.document_id )
179179
class Meta:
180180
db_table = 'ipr_rfcs'
181181
class Admin:

ietf/ipr/related.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ def set_related(obj, rel, target):
2828
if not hasattr(obj, "related"):
2929
obj.related = target
3030
obj.relation = display_relation[rel]
31+
return obj
3132

3233
def set_relation(first, rel, second):
3334
set_related(first, rel, second)

ietf/ipr/search.py

Lines changed: 61 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,53 @@
77
from ietf.utils import log
88

99

10+
def mark_last_doc(iprs):
11+
for item in iprs:
12+
if item.drafts.count():
13+
item.last_draft = item.drafts.all()[int(item.drafts.count())-1]
14+
if item.rfcs.count():
15+
item.last_rfc = item.rfcs.all()[int(item.rfcs.count())-1]
16+
17+
def mark_related_doc(iprs):
18+
for item in iprs:
19+
print "*** Item:", item
20+
for entry in item.drafts.all():
21+
print " ** Entry:", entry
22+
print " * Doc:", entry.document
23+
related_docs(entry.document, [])
24+
print " Doc relation:", entry.document.relation
25+
print " Doc related :", entry.document.related
26+
for entry in item.rfcs.all():
27+
print " ** Entry:", entry
28+
print " * Doc:", entry.document
29+
related_docs(entry.document, [])
30+
print " Doc relation:", entry.document.relation
31+
print " Doc related :", entry.document.related
32+
33+
def unique_iprs(iprs):
34+
ids = []
35+
unique = []
36+
for ipr in iprs:
37+
if not ipr.ipr_id in ids:
38+
ids += [ ipr.ipr_id ]
39+
unique += [ ipr ]
40+
return unique
41+
42+
def iprs_from_docs(docs):
43+
iprs = []
44+
for doc in docs:
45+
if isinstance(doc, InternetDraft):
46+
disclosures = [ item.ipr for item in IprDraft.objects.filter(document=doc, ipr__status__in=[1,3]) ]
47+
elif isinstance(doc, Rfc):
48+
disclosures = [ item.ipr for item in IprRfc.objects.filter(document=doc, ipr__status__in=[1,3]) ]
49+
else:
50+
raise ValueError("Doc type is neither draft nor rfc: %s" % doc)
51+
if disclosures:
52+
doc.iprs = disclosures
53+
iprs += disclosures
54+
iprs = list(set(iprs))
55+
return iprs
56+
1057
def search(request, type="", q="", id=""):
1158
wgs = IETFWG.objects.filter(group_type__group_type_id=1).exclude(group_acronym__acronym='2000').select_related().order_by('acronym.acronym')
1259
args = request.REQUEST.items()
@@ -37,18 +84,7 @@ def search(request, type="", q="", id=""):
3784

3885
docs = related_docs(first, [])
3986
#docs = get_doclist.get_doclist(first)
40-
iprs = []
41-
for doc in docs:
42-
if isinstance(doc, InternetDraft):
43-
disclosures = [ item.ipr for item in IprDraft.objects.filter(document=doc, ipr__status__in=[1,3]) ]
44-
elif isinstance(doc, Rfc):
45-
disclosures = [ item.ipr for item in IprRfc.objects.filter(document=doc, ipr__status__in=[1,3]) ]
46-
else:
47-
raise ValueError("Doc type is neither draft nor rfc: %s" % doc)
48-
if disclosures:
49-
doc.iprs = disclosures
50-
iprs += disclosures
51-
iprs = list(set(iprs))
87+
iprs = iprs_from_docs(docs)
5288
return render("ipr/search_doc_result.html", {"q": q, "first": first, "iprs": iprs, "docs": docs})
5389
elif start.count():
5490
return render("ipr/search_doc_list.html", {"q": q, "docs": start })
@@ -62,11 +98,7 @@ def search(request, type="", q="", id=""):
6298
iprs = [ ipr for ipr in iprs if not ipr.updated_by.all() ]
6399
# Some extra information, to help us render 'and' between the
64100
# last two documents in a sequence
65-
for ipr in iprs:
66-
if ipr.drafts.count():
67-
ipr.last_draft = ipr.drafts.all()[int(ipr.drafts.count())-1]
68-
if ipr.rfcs.count():
69-
ipr.last_rfc = ipr.rfcs.all()[int(ipr.rfcs.count())-1]
101+
mark_last_doc(iprs)
70102
return render("ipr/search_holder_result.html", {"q": q, "iprs": iprs, "count": count } )
71103

72104
# Search by content of email or pagent_info field
@@ -75,7 +107,18 @@ def search(request, type="", q="", id=""):
75107

76108
# Search by wg acronym
77109
elif type == "wg_search":
78-
pass
110+
try:
111+
docs = list(InternetDraft.objects.filter(group__acronym=q))
112+
except:
113+
docs = []
114+
docs += [ draft.replaced_by for draft in docs if draft.replaced_by_id ]
115+
docs += list(Rfc.objects.filter(group_acronym=q))
116+
117+
docs = [ doc for doc in docs if doc.ipr.count() ]
118+
iprs = iprs_from_docs(docs)
119+
count = len(iprs)
120+
#mark_last_doc(iprs)
121+
return render("ipr/search_wg_result.html", {"q": q, "docs": docs, "iprs": iprs, "count": count } )
79122

80123
# Search by rfc and id title
81124
elif type == "title_search":

ietf/ipr/testurl.list

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
200 /ipr/search/?rfc_search=4444&option=rfc_search https://datatracker.ietf.org/public/ipr_search.cgi?option=rfc_search&rfc_search=4444 # Empty result, RFC search
1616
200 /ipr/about/ https://datatracker.ietf.org/public/ipr_disclosure.cgi
1717
200 /ipr/search/?patent_search=nortel&option=patent_search https://datatracker.ietf.org/public/ipr_search.cgi?option=patent_search&patent_search=nortel
18-
18+
200,sort,ignore:quote /ipr/search/?wg_search=dnsext&option=wg_search https://datatracker.ietf.org/public/ipr_search.cgi?option=wg_search&wg_search=dnsext
1919
200 /ipr/2006/
2020
200 /ipr/2006/feb/
2121
200 /ipr/by-date/

0 commit comments

Comments
 (0)