Make the search for specific draft name in IPR support both drafts and RFCs, clean up some related cruft

- Legacy-Id: 6775
This commit is contained in:
Ole Laursen 2013-12-02 17:29:17 +00:00
parent e9638cb1c2
commit 19da33d8ff
5 changed files with 108 additions and 151 deletions

View file

@ -357,14 +357,6 @@ def agenda_documents(request):
sections = agenda_sections()
fill_in_agenda_docs(date, sections, docs_by_date[d])
for doc in docs_by_date[d]:
if doc.type_id=='draft':
if doc.get_state_slug() != "rfc":
doc.iprUrl = "/ipr/search?option=document_search&id_document_tag=" + str(doc.name)
else:
doc.iprUrl = "/ipr/search?option=rfc_search&rfc_search=" + str(doc.rfc_number())
doc.iprCount = len(doc.ipr())
telechats.append({
"date":date,
"sections": sorted((num, section) for num, section in sections.iteritems()

View file

@ -39,38 +39,34 @@ def patent_file_search(url, q):
return q in text
return False
def search(request, type="", q="", id=""):
def search(request):
wgs = Group.objects.filter(type="wg").select_related().order_by("acronym")
args = request.REQUEST.items()
if args:
for key, value in args:
if key == "option":
type = value
if re.match(".*search", key):
q = value
if re.match(".*id", key):
id = value
if (type and q) or id:
#log("Got query: type=%s, q=%s, id=%s" % (type, q, id))
search_type = request.GET.get("option")
if search_type:
docid = request.GET.get("id") or request.GET.get("id_document_tag") or ""
q = ""
for key, value in request.GET.items():
if key.endswith("search"):
q = value
if search_type and (q or docid):
# Search by RFC number or draft-identifier
# Document list with IPRs
if type in ["document_search", "rfc_search"]:
if search_type in ["document_search", "rfc_search"]:
doc = q
if type == "document_search":
if q:
if docid:
start = DocAlias.objects.filter(name=docid)
else:
if search_type == "document_search":
q = normalize_draftname(q)
start = DocAlias.objects.filter(name__contains=q, name__startswith="draft")
if id:
start = DocAlias.objects.filter(name=id)
if type == "rfc_search":
if q:
try:
q = int(q, 10)
except:
q = -1
start = DocAlias.objects.filter(name__contains=q, name__startswith="rfc")
if start.count() == 1:
elif search_type == "rfc_search":
start = DocAlias.objects.filter(name="rfc%s" % q.lstrip("0"))
if len(start) == 1:
first = start[0]
doc = str(first)
docs = related_docs(first)
@ -78,7 +74,7 @@ def search(request, type="", q="", id=""):
iprs.sort(key=lambda x: (x.submitted_date, x.ipr_id))
return render("ipr/search_doc_result.html", {"q": q, "iprs": iprs, "docs": docs, "doc": doc },
context_instance=RequestContext(request) )
elif start.count():
elif start:
return render("ipr/search_doc_list.html", {"q": q, "docs": start },
context_instance=RequestContext(request) )
else:
@ -87,7 +83,7 @@ def search(request, type="", q="", id=""):
# Search by legal name
# IPR list with documents
elif type == "patent_search":
elif search_type == "patent_search":
iprs = IprDetail.objects.filter(legal_name__icontains=q, status__in=[1,3]).order_by("-submitted_date", "-ipr_id")
count = iprs.count()
iprs = [ ipr for ipr in iprs if not ipr.updated_by.all() ]
@ -96,7 +92,7 @@ def search(request, type="", q="", id=""):
# Search by content of email or pagent_info field
# IPR list with documents
elif type == "patent_info_search":
elif search_type == "patent_info_search":
if len(q) < 3:
return render("ipr/search_error.html", {"q": q, "error": "The search string must contain at least three characters" },
context_instance=RequestContext(request) )
@ -119,7 +115,7 @@ def search(request, type="", q="", id=""):
# Search by wg acronym
# Document list with IPRs
elif type == "wg_search":
elif search_type == "wg_search":
docs = list(DocAlias.objects.filter(document__group__acronym=q))
related = []
for doc in docs:
@ -136,7 +132,7 @@ def search(request, type="", q="", id=""):
# Search by rfc and id title
# Document list with IPRs
elif type == "title_search":
elif search_type == "title_search":
docs = list(DocAlias.objects.filter(document__title__icontains=q))
related = []
for doc in docs:
@ -153,7 +149,7 @@ def search(request, type="", q="", id=""):
# Search by title of IPR disclosure
# IPR list with documents
elif type == "ipr_title_search":
elif search_type == "ipr_title_search":
iprs = IprDetail.objects.filter(title__icontains=q, status__in=[1,3]).order_by("-submitted_date", "-ipr_id")
count = iprs.count()
iprs = [ ipr for ipr in iprs if not ipr.updated_by.all() ]
@ -161,7 +157,7 @@ def search(request, type="", q="", id=""):
context_instance=RequestContext(request) )
else:
raise Http404("Unexpected search type in IPR query: %s" % type)
raise Http404("Unexpected search type in IPR query: %s" % search_type)
return HttpResponseRedirect(request.path)
return render("ipr/search.html", {"wgs": wgs}, context_instance=RequestContext(request))

View file

@ -1,36 +1,5 @@
{% comment %}
Copyright (C) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
All rights reserved. Contact: Pasi Eronen <pasi.eronen@nokia.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of the Nokia Corporation and/or its
subsidiary(-ies) nor the names of its contributors may be used
to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
{% endcomment %}
{% load ietf_filters %}<td class="ipr">
{% if doc.iprCount %}<a href="{{ doc.iprUrl }}" rel="nofollow"> IPR:{{ doc.iprCount }} </a>{% endif %}
<td class="ipr">
{% if doc.type_id == "draft" and doc.ipr %}
<a href="{% url ipr_search %}?option=document_search&id={{ doc.canonical_name }}" rel="nofollow">IPR: {{ doc.ipr|length }}</a>
{% endif %}
</td>

View file

@ -11,92 +11,92 @@ label { float:left; width: 200px; }
<h1>IPR Search</h1>
<h2>Document Search</h2>
<div class="ietf-box search-form-box">
<form>
<input type="hidden" name="option" value="document_search">
<form>
<input type="hidden" name="option" value="document_search">
<label>I-D name (draft-...):</label>
<input type="text" name="document_search" size="30">
<input type="submit" value="SEARCH" >
</form>
<label>I-D name (draft-...):</label>
<input type="text" name="document_search" size="30">
<input type="submit" value="SEARCH" >
</form>
<script language="javascript"><!--
function IsNumeric(strString) {
var strValidChars = "0123456789.-";
var strChar;
var blnResult = true;
<script language="javascript"><!--
function IsNumeric(strString) {
var strValidChars = "0123456789.-";
var strChar;
var blnResult = true;
if (strString.length == 0) return false;
if (strString.length == 0) return false;
for (i = 0; i < strString.length && blnResult == true; i++)
{
strChar = strString.charAt(i);
if (strValidChars.indexOf(strChar) == -1)
{
blnResult = false;
}
}
return blnResult;
}
for (i = 0; i < strString.length && blnResult == true; i++)
{
strChar = strString.charAt(i);
if (strValidChars.indexOf(strChar) == -1)
{
blnResult = false;
}
}
return blnResult;
}
function check_numeric(val) {
if (IsNumeric(val)) {
return true;
} else {
alert ("Please enter numerics only");
return false;
}
return false;
}
// -->
</script>
<form name="form_rfc_search">
<input type="hidden" name="option" value="rfc_search">
<label>RFC Number:</label>
<input type="text" name="rfc_search" size="8">
<input type="submit" value="SEARCH" onClick="return check_numeric(document.form_rfc_search.rfc_search.value);">
</form>
function check_numeric(val) {
if (IsNumeric(val)) {
return true;
} else {
alert ("Please enter numerics only");
return false;
}
return false;
}
// -->
</script>
<form name="form_rfc_search">
<input type="hidden" name="option" value="rfc_search">
<label>RFC Number:</label>
<input type="text" name="rfc_search" size="8">
<input type="submit" value="SEARCH" onClick="return check_numeric(document.form_rfc_search.rfc_search.value);">
</form>
</div>
<h2>Keyword Search</h2>
<div class="ietf-box search_form_box">
<form>
<input type="hidden" name="option" value="patent_search">
<label>Name of patent owner/applicant:</label>
<input type="text" name="patent_search" size="30">
<input type="submit" value="SEARCH">
</form>
<form>
<input type="hidden" name="option" value="patent_info_search"/>
<label>Characters in patent information (Full/Partial):</label>
<input type="text" name="patent_info_search" size="30"/>
<input type="submit" value="SEARCH"/>
</form>
<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>
<form>
<input type="hidden" name="option" value="patent_search">
<label>Name of patent owner/applicant:</label>
<input type="text" name="patent_search" size="30">
<input type="submit" value="SEARCH">
</form>
<form>
<input type="hidden" name="option" value="patent_info_search"/>
<label>Characters in patent information (Full/Partial):</label>
<input type="text" name="patent_info_search" size="30"/>
<input type="submit" value="SEARCH"/>
</form>
<form>
<input type="hidden" name="option" value="wg_search">
<label>Working group name:</label>
<select name="wg_search">
<option value="">--Select WG</option>
{% for wg in wgs %}
<option value="{{ wg.acronym }}">{{ wg.acronym }}</option>{% endfor %}
</select>
<input type="submit" value="SEARCH" width="15">
</form>
<form>
<input type="hidden" name="option" value="title_search"/>
<label>Words in document title:</label>
<input type="text" name="title_search" size="30" />
<input type="submit" value="SEARCH" />
</form>
<form>
<input type="hidden" name="option" value="ipr_title_search" />
<label>Words in IPR disclosure title:</label>
<input type="text" name="ipr_title_search" size="30" />
<input type="submit" value="SEARCH" />
</form>
<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>
<form>
<input type="hidden" name="option" value="wg_search">
<label>Working group name:</label>
<select name="wg_search">
<option value="">--Select WG</option>
{% for wg in wgs %}
<option value="{{ wg.acronym }}">{{ wg.acronym }}</option>{% endfor %}
</select>
<input type="submit" value="SEARCH" width="15">
</form>
<form>
<input type="hidden" name="option" value="title_search"/>
<label>Words in document title:</label>
<input type="text" name="title_search" size="30" />
<input type="submit" value="SEARCH" />
</form>
<form>
<input type="hidden" name="option" value="ipr_title_search" />
<label>Words in IPR disclosure title:</label>
<input type="text" name="ipr_title_search" size="30" />
<input type="submit" value="SEARCH" />
</form>
</div>
<p><a href="{% url ietf.ipr.views.showlist %}">Back to IPR Disclosure Page</a></p>

View file

@ -8,7 +8,7 @@
<h3>Please select one of following I-Ds</h3>
<ul>
{% for docalias in docs %}
<li><a href="?option=document_search&id_document_tag={{ docalias.document }}">{{ docalias.document }}</a></li>
<li><a href="?option=document_search&id={{ docalias.name }}">{{ docalias.name }}</a></li>
{% endfor %}
</ul>
{% endblock %}