fix: Include missing related drafts in IPR searches (#7836)
* fix: Include missing related drafts in IPR searches * refactor: extract drafts, sort docs * chore: indent loop and conditionals to improve readability * test: handle whitespaces added to IPR search result page --------- Co-authored-by: Robert Sparks <rjsparks@nostrum.com>
This commit is contained in:
parent
d8d52eedbf
commit
80599f29f0
ietf
|
@ -24,6 +24,7 @@ from ietf.doc.factories import (
|
|||
RfcFactory,
|
||||
NewRevisionDocEventFactory
|
||||
)
|
||||
from ietf.doc.utils import prettify_std_name
|
||||
from ietf.group.factories import RoleFactory
|
||||
from ietf.ipr.factories import (
|
||||
HolderIprDisclosureFactory,
|
||||
|
@ -192,6 +193,38 @@ class IprTests(TestCase):
|
|||
r = self.client.get(url + "?submit=rfc&rfc=321")
|
||||
self.assertContains(r, ipr.title)
|
||||
|
||||
rfc_new = RfcFactory(rfc_number=322)
|
||||
rfc_new.relateddocument_set.create(relationship_id="obs", target=rfc)
|
||||
|
||||
# find RFC 322 which obsoletes RFC 321 whose draft has IPR
|
||||
r = self.client.get(url + "?submit=rfc&rfc=322")
|
||||
self.assertContains(r, ipr.title)
|
||||
self.assertContains(r, "Total number of IPR disclosures found: <b>1</b>")
|
||||
self.assertContains(r, "Total number of documents searched: <b>3</b>.")
|
||||
self.assertContains(
|
||||
r,
|
||||
f"""Results for <a href="/doc/{rfc_new.name}/">{prettify_std_name(rfc_new.name)}</a>
|
||||
("{rfc_new.title}")""",
|
||||
)
|
||||
self.assertContains(
|
||||
r,
|
||||
f"""Results for <a href="/doc/{rfc.name}/">{prettify_std_name(rfc.name)}</a>
|
||||
("{rfc.title}"), which
|
||||
|
||||
was obsoleted by
|
||||
<a href="/doc/{rfc_new.name}/">{prettify_std_name(rfc_new.name)}</a>
|
||||
("{rfc_new.title}")""",
|
||||
)
|
||||
self.assertContains(
|
||||
r,
|
||||
f"""Results for <a href="/doc/{draft.name}/">{prettify_std_name(draft.name)}</a>
|
||||
("{draft.title}"), which
|
||||
|
||||
became rfc
|
||||
<a href="/doc/{rfc.name}/">{prettify_std_name(rfc.name)}</a>
|
||||
("{rfc.title}")""",
|
||||
)
|
||||
|
||||
# find by patent owner
|
||||
r = self.client.get(url + "?submit=holder&holder=%s" % ipr.holder_legal_name)
|
||||
self.assertContains(r, ipr.title)
|
||||
|
|
|
@ -689,11 +689,41 @@ def search(request):
|
|||
if len(start) == 1:
|
||||
first = start[0]
|
||||
doc = first
|
||||
docs = related_docs(first)
|
||||
iprs = iprs_from_docs(docs,states=states)
|
||||
docs = set([first])
|
||||
docs.update(
|
||||
related_docs(
|
||||
first, relationship=("replaces", "obs"), reverse_relationship=()
|
||||
)
|
||||
)
|
||||
docs.update(
|
||||
set(
|
||||
[
|
||||
draft
|
||||
for drafts in [
|
||||
related_docs(
|
||||
d, relationship=(), reverse_relationship=("became_rfc",)
|
||||
)
|
||||
for d in docs
|
||||
]
|
||||
for draft in drafts
|
||||
]
|
||||
)
|
||||
)
|
||||
docs.discard(None)
|
||||
docs = sorted(
|
||||
docs,
|
||||
key=lambda d: (
|
||||
d.rfc_number if d.rfc_number is not None else 0,
|
||||
d.became_rfc().rfc_number if d.became_rfc() else 0,
|
||||
),
|
||||
reverse=True,
|
||||
)
|
||||
iprs = iprs_from_docs(docs, states=states)
|
||||
template = "ipr/search_doc_result.html"
|
||||
updated_docs = related_docs(first, ('updates',))
|
||||
related_iprs = list(set(iprs_from_docs(updated_docs, states=states)) - set(iprs))
|
||||
updated_docs = related_docs(first, ("updates",))
|
||||
related_iprs = list(
|
||||
set(iprs_from_docs(updated_docs, states=states)) - set(iprs)
|
||||
)
|
||||
# multiple matches, select just one
|
||||
elif start:
|
||||
docs = start
|
||||
|
|
|
@ -54,16 +54,27 @@
|
|||
</tr>
|
||||
</thead>
|
||||
|
||||
{% for doc in docs %}
|
||||
{% for d in docs %}
|
||||
<tbody>
|
||||
<tr>
|
||||
<th scope="col" class="table-info" colspan="3">
|
||||
Results for {{ doc.name|prettystdname|urlize_ietf_docs }} ("{{ doc.title }}"){% if not forloop.first %}{% if doc.related %}, which was {{ doc.relation|lower }} {{ doc.related.source|prettystdname|urlize_ietf_docs }} ("{{ doc.related.source.title }}"){% endif %}{% endif %}
|
||||
Results for {{ d.name|prettystdname|urlize_ietf_docs }}
|
||||
("{{ d.title }}"){% if d != doc and d.related %}, which
|
||||
{% if d == d.related.source %}
|
||||
{{ d.relation|lower }}
|
||||
{{ d.related.target|prettystdname|urlize_ietf_docs }}
|
||||
("{{ d.related.target.title }}")
|
||||
{% else %}
|
||||
was {{ d.relation|lower }}
|
||||
{{ d.related.source|prettystdname|urlize_ietf_docs }}
|
||||
("{{ d.related.source.title }}")
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</th>
|
||||
</tr>
|
||||
</tbody>
|
||||
<tbody>
|
||||
{% with doc.iprdocrel_set.all as doc_iprs %}
|
||||
{% with d.iprdocrel_set.all as doc_iprs %}
|
||||
{% if doc_iprs %}
|
||||
{% for ipr in doc_iprs %}
|
||||
{% if ipr.disclosure.state_id in states %}
|
||||
|
@ -81,7 +92,7 @@
|
|||
<td></td>
|
||||
<td></td>
|
||||
<td>
|
||||
No IPR disclosures have been submitted directly on {{ doc.name|prettystdname|urlize_ietf_docs }}{% if iprs %},
|
||||
No IPR disclosures have been submitted directly on {{ d.name|prettystdname|urlize_ietf_docs }}{% if iprs %},
|
||||
but there are disclosures on {% if docs|length == 2 %}a related document{% else %}related documents{% endif %}, listed on this page{% endif %}.
|
||||
</td>
|
||||
</tr>
|
||||
|
|
Loading…
Reference in a new issue