Skip to content

Commit b030e37

Browse files
committed
* Added IPR patent info search
* Added IPR patent info search term error pages * Fixed empty holder search template error * Some refactoring to have one ipr->doc relation instead of both ->drafts and -> rfcs - Legacy-Id: 687
1 parent 3fdaea8 commit b030e37

7 files changed

Lines changed: 58 additions & 20 deletions

File tree

ietf/ipr/models.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ class IprDetail(models.Model):
115115

116116
def __str__(self):
117117
return self.title
118+
def docs(self):
119+
return list(self.drafts.all()) + list(self.rfcs.all())
118120
def get_absolute_url(self):
119121
return "/ipr/ipr-%s" % self.ipr_id
120122
class Meta:

ietf/ipr/search.py

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import re
2+
import os.path
23
import django.utils.html
34
from django.shortcuts import render_to_response as render
45
from django.template import RequestContext
6+
from django.conf import settings
57
from ietf.idtracker.models import IETFWG, InternetDraft, Rfc
68
from ietf.ipr.models import IprRfc, IprDraft, IprDetail
79
from ietf.ipr.related import related_docs
@@ -10,10 +12,10 @@
1012

1113
def mark_last_doc(iprs):
1214
for item in iprs:
13-
if item.drafts.count():
14-
item.last_draft = item.drafts.all()[int(item.drafts.count())-1]
15-
if item.rfcs.count():
16-
item.last_rfc = item.rfcs.all()[int(item.rfcs.count())-1]
15+
docs = item.docs()
16+
count = len(docs)
17+
if count > 1:
18+
item.last_draft = docs[count-1]
1719

1820
def mark_related_doc(iprs):
1921
for item in iprs:
@@ -46,6 +48,19 @@ def iprs_from_docs(docs):
4648
iprs = list(set(iprs))
4749
return iprs, docs
4850

51+
def patent_file_search(url, q):
52+
if url:
53+
fname = url.split("/")[-1]
54+
fpath = os.path.join(settings.IPR_DOCUMENT_PATH, fname)
55+
#print "*** Checking file", fpath
56+
if os.path.exists(fpath):
57+
#print "*** Found file", fpath
58+
file = open(fpath)
59+
text = file.read()
60+
file.close
61+
return q in text
62+
return False
63+
4964
def search(request, type="", q="", id=""):
5065
wgs = IETFWG.objects.filter(group_type__group_type_id=1).exclude(group_acronym__acronym='2000').select_related().order_by('acronym.acronym')
5166
args = request.REQUEST.items()
@@ -101,7 +116,28 @@ def search(request, type="", q="", id=""):
101116
# Search by content of email or pagent_info field
102117
# IPR list with documents
103118
elif type == "patent_info_search":
104-
pass
119+
if len(q) < 3:
120+
return render("ipr/search_error.html", {"q": q, "error": "The search string must contain at least three characters" },
121+
context_instance=RequestContext(request) )
122+
digits = re.search("[0-9]", q)
123+
if not digits:
124+
return render("ipr/search_error.html", {"q": q, "error": "The search string must contain at least one digit" },
125+
context_instance=RequestContext(request) )
126+
iprs = []
127+
for ipr in IprDetail.objects.filter(status__in=[1,3]):
128+
if ((q in ipr.patents) |
129+
patent_file_search(ipr.legacy_url_0, q) |
130+
patent_file_search(ipr.legacy_url_1, q) |
131+
patent_file_search(ipr.legacy_url_2, q) ):
132+
iprs.append(ipr)
133+
count = len(iprs)
134+
iprs = [ ipr for ipr in iprs if not ipr.updated_by.all() ]
135+
# Some extra information, to help us render 'and' between the
136+
# last two documents in a sequence
137+
iprs.sort(key=lambda x: x.ipr_id, reverse=True) # Reverse sort
138+
mark_last_doc(iprs)
139+
return render("ipr/search_patent_result.html", {"q": q, "iprs": iprs, "count": count },
140+
context_instance=RequestContext(request) )
105141

106142
# Search by wg acronym
107143
# Document list with IPRs

ietf/ipr/testurl.list

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@
2121
200,sort,ignore:quote /ipr/search/?wg_search=acct&option=wg_search https://datatracker.ietf.org/public/ipr_search.cgi?option=wg_search&wg_search=acct # Empty result
2222
200,sort,ignore:quote /ipr/search/?option=title_search&title_search=AAA https://datatracker.ietf.org/public/ipr_search.cgi?option=title_search&title_search=AAA
2323
200,sort,ignore:quote /ipr/search/?option=title_search&title_search=AAAxz https://datatracker.ietf.org/public/ipr_search.cgi?option=title_search&title_search=AAAxz # Empty result
24+
200,sort /ipr/search/?patent_info_search=123&option=patent_info_search https://datatracker.ietf.org/public/ipr_search.cgi?option=patent_info_search&patent_info_search=123
25+
200,sort /ipr/search/?patent_info_search=31415&option=patent_info_search https://datatracker.ietf.org/public/ipr_search.cgi?option=patent_info_search&patent_info_search=31415 # Empty result
26+
200 /ipr/search/?patent_info_search=12&option=patent_info_search https://datatracker.ietf.org/public/ipr_search.cgi?option=patent_info_search&patent_info_search=12 # Error: at least 3 characters
27+
200 /ipr/search/?patent_info_search=abc&option=patent_info_search https://datatracker.ietf.org/public/ipr_search.cgi?option=patent_info_search&patent_info_search=abc # Error: at least 1 digit
28+
29+
2430
200 /ipr/about/ https://datatracker.ietf.org/public/ipr_disclosure.cgi
2531
200 /ipr/2006/
2632
200 /ipr/2006/feb/

ietf/settings.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,8 @@
153153
# The name of the method to use to invoke the test suite
154154
TEST_RUNNER = 'ietf.tests.run_tests'
155155

156+
IPR_DOCUMENT_PATH = '/home/master-site/ftp/data/ietf/IPR'
157+
156158
# Put SECRET_KEY in here, or any other sensitive or site-specific
157159
# changes. DO NOT commit settings_local.py to svn.
158160
from settings_local import *
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{% extends "ipr/search_result.html" %}
22
{% load ietf_filters %}
33
{% block search_header %}{% if not count %}Search result on {{ q }}{% else %}Patent Owner/Applicant Search Result{% endif %}{% endblock %}</b></td></tr>
4-
{% block item_intro %}IPR that was submitted by <b><i>{{ q }}</i></b>,{% endblock %}
4+
{% block intro_prefix %}IPR that was submitted by <b><i>{{ q }}</i></b>, and{% endblock %}
Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
{% extends "ipr/search_result.html" %}
22
{% load ietf_filters %}
3-
{% block search_header %}Patent Information Search Result{% endblock %}
4-
{% block into_prefix %}
5-
IPR that contains the string {{ q }} in the "Disclosure of Patent Information"
6-
section of the form, or in the body of the text (for disclosures submitted by
7-
e-mail), and
8-
{% endblock %}
9-
3+
{% block search_header %}{% if not count %}Search result on {{ q }}{% else %}Patent Information Search Result{% endif %}{% endblock %}
4+
{% block search_failed %}No IPR disclosures with the word(s) "<i>{{ q }}</i>" in the Patent Information have been submitted{% endblock %}
5+
{% block intro_prefix %}IPR that contains the string <b><i>{{ q }}</i></b> in the "Disclosure of Patent Information" section of the form, or in the body of the text (for disclosures submitted by e-mail), and{% endblock %}

ietf/templates/ipr/search_result.html

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ <h2>IPR Disclosures</h2>
1414
{% if not iprs %}
1515
<tr>
1616
<td></td>
17-
<td colspan="2"><b>No IPR disclosures have been submitted by the <i>{{ q }}</i></b></td>
17+
<td colspan="2"><b>{% block search_failed %}No IPR disclosures have been submitted by the <i>{{ q }}</i>{% endblock %}</b></td>
1818
</tr>
1919
{% else %}
2020
<tr><td colspan="3">Total number of IPR disclosures found: {{ count }} </td></tr>
@@ -29,12 +29,8 @@ <h2>IPR Disclosures</h2>
2929
is not related to a specific IETF contribution.
3030
{% else %}
3131
is related to
32-
{% for item in ipr.drafts.all %}
33-
{% ifnotequal ipr.drafts.count 1 %}{% ifequal item ipr.last_draft %}<b> and </b>{% endifequal %}{% endifnotequal %}
34-
<b><i>{{ item.document }}, "{{ item.document.title }},"</i></b>{% if item.document.related %}, {{ item.document.relation }} {{ item.document.related }}, "{{ item.document.related.title }}"{% endif %}
35-
{% endfor %}
36-
{% for item in ipr.rfcs.all %}
37-
{% ifnotequal ipr.rfcs.count 1 %}{% ifequal item ipr.last_rfc %} and {% endifequal %}{% endifnotequal %}
32+
{% for item in ipr.docs %}
33+
{% ifequal item ipr.last_draft %}<b> and </b>{% endifequal %}
3834
<b><i>{{ item.document }}, "{{ item.document.title }},"</i></b>{% if item.document.related %}, {{ item.document.relation }} {{ item.document.related }}, "{{ item.document.related.title }}"{% endif %}
3935
{% endfor %}
4036
{% endif %}

0 commit comments

Comments
 (0)