From 53be2c37931290698272fd576951fc0854ce3543 Mon Sep 17 00:00:00 2001 From: Robert Sparks Date: Fri, 18 Aug 2023 07:47:12 -0500 Subject: [PATCH 1/4] feat: require draft revisions in ipr disclosures. Explain missing ones. (#6160) * feat: require draft revisions in ipr disclosures. Explain missing ones. * chore: update copyrights * chore: address review comments * fix: draft should be Internet-Draft * test: cover single revision case --- ietf/ipr/factories.py | 10 ++- ietf/ipr/forms.py | 11 ++- ietf/ipr/templatetags/ipr_filters.py | 40 +++++++++- ietf/ipr/tests.py | 109 ++++++++++++++++++++++++++- ietf/templates/ipr/details_view.html | 16 +++- 5 files changed, 179 insertions(+), 7 deletions(-) diff --git a/ietf/ipr/factories.py b/ietf/ipr/factories.py index 5e948e010b..d4a1f2eb4e 100644 --- a/ietf/ipr/factories.py +++ b/ietf/ipr/factories.py @@ -1,4 +1,4 @@ -# Copyright The IETF Trust 2018-2020, All Rights Reserved +# Copyright The IETF Trust 2018-2023, All Rights Reserved # -*- coding: utf-8 -*- @@ -95,3 +95,11 @@ class Meta: disclosure = factory.SubFactory(IprDisclosureBaseFactory) desc = factory.Faker('sentence') +class IprDocRelFactory(factory.django.DjangoModelFactory): + class Meta: + model = IprDocRel + + disclosure = factory.SubFactory(HolderIprDisclosureFactory) + document = factory.SubFactory("ietf.doc.factories.IndividualDraftFactory") + revisions = "00" + sections = "" diff --git a/ietf/ipr/forms.py b/ietf/ipr/forms.py index 5f6c76c377..cd4b406f95 100644 --- a/ietf/ipr/forms.py +++ b/ietf/ipr/forms.py @@ -1,4 +1,4 @@ -# Copyright The IETF Trust 2014-2020, All Rights Reserved +# Copyright The IETF Trust 2014-2023, All Rights Reserved # -*- coding: utf-8 -*- @@ -105,6 +105,15 @@ class Meta: } help_texts = { 'sections': 'Sections' } + def clean(self): + cleaned_data = super().clean() + revisions = cleaned_data.get("revisions") + document = cleaned_data.get("document") + if not document.name.startswith("rfc"): + if revisions.strip() == "": + self.add_error("revisions", "Revisions of this Internet-Draft for which this disclosure is relevant must be specified.") + return cleaned_data + patent_number_help_text = "Enter one or more comma-separated patent publication or application numbers as two-letter country code and serial number, e.g.: US62/123456 or WO2017123456. Do not include thousands-separator commas in serial numbers. It is preferable to use individual disclosures for each patent, even if this field permits multiple patents to be listed, in order to get inventor, title, and date information below correct." validate_patent_number = RegexValidator( regex=(r"^(" diff --git a/ietf/ipr/templatetags/ipr_filters.py b/ietf/ipr/templatetags/ipr_filters.py index 21d5579bf9..0130387500 100644 --- a/ietf/ipr/templatetags/ipr_filters.py +++ b/ietf/ipr/templatetags/ipr_filters.py @@ -1,10 +1,14 @@ -# Copyright The IETF Trust 2014-2020, All Rights Reserved +# Copyright The IETF Trust 2014-2023, All Rights Reserved # -*- coding: utf-8 -*- +import debug # pyflakes: ignore + from django import template from django.utils.html import format_html +from ietf.doc.models import NewRevisionDocEvent + register = template.Library() @@ -26,3 +30,37 @@ def render_message_for_history(msg): @register.filter def to_class_name(value): return value.__class__.__name__ + +def draft_rev_at_time(iprdocrel): + draft = iprdocrel.document.document + event = iprdocrel.disclosure.get_latest_event_posted() + if event is None: + return ("","The Internet-Draft's revision at the time this disclosure was posted could not be determined.") + time = event.time + if not NewRevisionDocEvent.objects.filter(doc=draft).exists(): + return ("","The Internet-Draft's revision at the time this disclosure was posted could not be determined.") + rev_event_before = NewRevisionDocEvent.objects.filter(doc=draft, time__lte=time).order_by('-time').first() + if rev_event_before is None: + return ("","The Internet-Draft's initial submission was after this disclosure was posted.") + else: + return(rev_event_before.rev, "") + +@register.filter +def no_revisions_message(iprdocrel): + draft = iprdocrel.document.document + if draft.type_id != "draft" or iprdocrel.revisions.strip() != "": + return "" + rev_at_time, exception = draft_rev_at_time(iprdocrel) + current_rev = draft.rev + + first_line = "No revisions for this Internet-Draft were specified in this disclosure." + contact_line = "Contact the discloser or patent holder if there are questions about which revisions this disclosure pertains to." + + if current_rev == "00": + return f"{first_line} However, there is only one revision of this Internet-Draft." + + if rev_at_time: + return f"{first_line} The Internet-Draft's revision was {rev_at_time} at the time this disclosure was posted. {contact_line}" + else: + return f"{first_line} {exception} {contact_line}" + diff --git a/ietf/ipr/tests.py b/ietf/ipr/tests.py index fd07821af3..65d8323eb1 100644 --- a/ietf/ipr/tests.py +++ b/ietf/ipr/tests.py @@ -1,4 +1,4 @@ -# Copyright The IETF Trust 2009-2020, All Rights Reserved +# Copyright The IETF Trust 2009-2023, All Rights Reserved # -*- coding: utf-8 -*- @@ -16,13 +16,24 @@ import debug # pyflakes:ignore from ietf.doc.models import DocAlias -from ietf.doc.factories import DocumentFactory, WgDraftFactory, WgRfcFactory +from ietf.doc.factories import ( + DocumentFactory, + WgDraftFactory, + WgRfcFactory, + NewRevisionDocEventFactory +) from ietf.group.factories import RoleFactory -from ietf.ipr.factories import HolderIprDisclosureFactory, GenericIprDisclosureFactory, IprEventFactory +from ietf.ipr.factories import ( + HolderIprDisclosureFactory, + GenericIprDisclosureFactory, + IprDocRelFactory, + IprEventFactory +) from ietf.ipr.mail import (process_response_email, get_reply_to, get_update_submitter_emails, get_pseudo_submitter, get_holders, get_update_cc_addrs) from ietf.ipr.models import (IprDisclosureBase,GenericIprDisclosure,HolderIprDisclosure, ThirdPartyIprDisclosure) +from ietf.ipr.templatetags.ipr_filters import no_revisions_message from ietf.ipr.utils import get_genitive, get_ipr_summary from ietf.mailtrigger.utils import gather_address_lists from ietf.message.models import Message @@ -305,6 +316,38 @@ def test_new_specific(self): r = self.client.post(url, data) self.assertContains(r, "Your IPR disclosure has been submitted", msg_prefix="Checked patent number: %s" % patent_number) + def test_new_specific_no_revision(self): + draft = WgDraftFactory() + WgRfcFactory() + url = urlreverse("ietf.ipr.views.new", kwargs={ "type": "specific" }) + + # successful post + empty_outbox() + data = { + "holder_legal_name": "Test Legal", + "holder_contact_name": "Test Holder", + "holder_contact_email": "test@holder.com", + "holder_contact_info": "555-555-0100", + "ietfer_name": "Test Participant", + "ietfer_contact_info": "555-555-0101", + "iprdocrel_set-TOTAL_FORMS": 2, + "iprdocrel_set-INITIAL_FORMS": 0, + "iprdocrel_set-0-document": draft.docalias.first().pk, + "iprdocrel_set-1-document": DocAlias.objects.filter(name__startswith="rfc").first().pk, + "patent_number": "SE12345678901", + "patent_inventor": "A. Nonymous", + "patent_title": "A method of transferring bits", + "patent_date": "2000-01-01", + "has_patent_pending": False, + "licensing": "royalty-free", + "submitter_name": "Test Holder", + "submitter_email": "test@holder.com", + } + r = self.client.post(url, data) + self.assertEqual(r.status_code, 200) + q = PyQuery(r.content) + self.assertTrue(q("#id_iprdocrel_set-0-revisions").hasClass("is-invalid")) + def test_new_thirdparty(self): """Add a new third-party disclosure. Note: submitter does not need to be logged in. """ @@ -761,4 +804,64 @@ def test_docevent_creation(self): removed_docevent = doc.docevent_set.filter(type='removed_related_ipr').first() self.assertIn(ipr.title, removed_docevent.desc, 'IprDisclosure title does not appear in DocEvent desc when removed') + + def test_no_revisions_message(self): + draft = WgDraftFactory(rev="02") + now = timezone.now() + for rev in range(0,3): + NewRevisionDocEventFactory(doc=draft, rev=f"{rev:02d}", time=now-datetime.timedelta(days=30*(2-rev))) + # Disclosure has non-empty revisions field on its related draft + iprdocrel = IprDocRelFactory(document=draft.docalias.first()) + IprEventFactory(type_id="posted",time=now,disclosure=iprdocrel.disclosure) + self.assertEqual( + no_revisions_message(iprdocrel), + "" + ) + + # Disclosure has more than one revision, none called out, disclosure after submissions + iprdocrel = IprDocRelFactory(document=draft.docalias.first(), revisions="") + IprEventFactory(type_id="posted",time=now,disclosure=iprdocrel.disclosure) + self.assertEqual( + no_revisions_message(iprdocrel), + "No revisions for this Internet-Draft were specified in this disclosure. The Internet-Draft's revision was 02 at the time this disclosure was posted. Contact the discloser or patent holder if there are questions about which revisions this disclosure pertains to." + ) + + # Disclosure has more than one revision, none called out, disclosure after 01 + iprdocrel = IprDocRelFactory(document=draft.docalias.first(), revisions="") + e = IprEventFactory(type_id="posted",disclosure=iprdocrel.disclosure) + e.time = now-datetime.timedelta(days=15) + e.save() + self.assertEqual( + no_revisions_message(iprdocrel), + "No revisions for this Internet-Draft were specified in this disclosure. The Internet-Draft's revision was 01 at the time this disclosure was posted. Contact the discloser or patent holder if there are questions about which revisions this disclosure pertains to." + ) + + # Disclosure has more than one revision, none called out, disclosure was before the 00 + iprdocrel = IprDocRelFactory(document=draft.docalias.first(), revisions="") + e = IprEventFactory(type_id="posted",disclosure=iprdocrel.disclosure) + e.time = now-datetime.timedelta(days=180) + e.save() + self.assertEqual( + no_revisions_message(iprdocrel), + "No revisions for this Internet-Draft were specified in this disclosure. The Internet-Draft's initial submission was after this disclosure was posted. Contact the discloser or patent holder if there are questions about which revisions this disclosure pertains to." + ) + + # disclosed draft has no NewRevisionDocEvents + draft = WgDraftFactory(rev="20") + draft.docevent_set.all().delete() + iprdocrel = IprDocRelFactory(document=draft.docalias.first(), revisions="") + IprEventFactory(type_id="posted",disclosure=iprdocrel.disclosure) + self.assertEqual( + no_revisions_message(iprdocrel), + "No revisions for this Internet-Draft were specified in this disclosure. The Internet-Draft's revision at the time this disclosure was posted could not be determined. Contact the discloser or patent holder if there are questions about which revisions this disclosure pertains to." + ) + + # disclosed draft has only one revision + draft = WgDraftFactory(rev="00") + iprdocrel = IprDocRelFactory(document=draft.docalias.first(), revisions="") + IprEventFactory(type_id="posted",disclosure=iprdocrel.disclosure) + self.assertEqual( + no_revisions_message(iprdocrel), + "No revisions for this Internet-Draft were specified in this disclosure. However, there is only one revision of this Internet-Draft." + ) diff --git a/ietf/templates/ipr/details_view.html b/ietf/templates/ipr/details_view.html index aa695aeee7..97a2af656a 100644 --- a/ietf/templates/ipr/details_view.html +++ b/ietf/templates/ipr/details_view.html @@ -1,5 +1,5 @@ {% extends "base.html" %} -{# Copyright The IETF Trust 2015, 2017. All Rights Reserved. #} +{# Copyright The IETF Trust 2015-2023. All Rights Reserved. #} {% load origin %} {% load ietf_filters ipr_filters textfilters %} {% block title %}IPR Details - {{ ipr.title }}{% endblock %} @@ -388,6 +388,13 @@

{{ iprdocrel.revisions }}
+ {% elif iprdocrel.doc_type == "Internet-Draft" %} +
+ Notice: +
+
+ {{ iprdocrel|no_revisions_message }} +
{% endif %} {% if iprdocrel.sections %}
@@ -427,6 +434,13 @@

{{ iprdocrel.revisions }}
+ {% elif iprdocrel.doc_type == "Internet-Draft" %} +
+ Notice: +
+
+ {{ iprdocrel|no_revisions_message }} +
{% endif %} {% if iprdocrel.sections %}
From aa955f0e9b7d7c98b6c467d2cf42e65b2c0f68fc Mon Sep 17 00:00:00 2001 From: Lars Eggert Date: Fri, 18 Aug 2023 21:41:02 +0300 Subject: [PATCH 2/4] fix: Replace deprecated bootstrap CSS classes with 5.3 ones (#6166) * fix: Replace deprecated bootstrap CSS classes with 5.3 ones * Fix test * Remove debug print --- ietf/doc/templatetags/ietf_filters.py | 3 ++- ietf/group/tests_review.py | 2 +- ietf/templates/base.html | 2 +- ietf/templates/doc/document_statement.html | 2 +- ietf/templates/doc/drafts_in_iesg_process.html | 2 +- ietf/templates/doc/review_assignment_summary.html | 2 +- ietf/templates/doc/review_request_summary.html | 4 ++-- ietf/templates/doc/search/search_results.html | 2 +- ietf/templates/doc/status_change/status_changes.html | 2 +- ietf/templates/group/active_adm.html | 2 +- ietf/templates/group/active_iabgroups.html | 2 +- ietf/templates/group/active_rfced.html | 2 +- ietf/templates/group/review_requests.html | 8 ++++---- ietf/templates/group/reviewer_overview.html | 2 +- ietf/templates/ipr/search_doc_result.html | 2 +- ietf/templates/ipr/search_doctitle_result.html | 2 +- ietf/templates/ipr/search_result.html | 2 +- ietf/templates/ipr/search_wg_result.html | 2 +- ietf/templates/submit/tool_instructions.html | 10 +++++----- 19 files changed, 28 insertions(+), 27 deletions(-) diff --git a/ietf/doc/templatetags/ietf_filters.py b/ietf/doc/templatetags/ietf_filters.py index 46cab63c96..9b4700bfb1 100644 --- a/ietf/doc/templatetags/ietf_filters.py +++ b/ietf/doc/templatetags/ietf_filters.py @@ -856,6 +856,7 @@ def badgeify(blob): (r"has issues", "warning", "exclamation-lg"), (r"assigned", "info", "person-plus-fill"), (r"will not review|overtaken by events|withdrawn", "secondary", "dash-lg"), + (r"no response", "warning", "question-lg"), ] text = str(blob) @@ -868,7 +869,7 @@ def badgeify(blob): return mark_safe( f""" - + {text.capitalize()} """ diff --git a/ietf/group/tests_review.py b/ietf/group/tests_review.py index af374f6765..60c11689bc 100644 --- a/ietf/group/tests_review.py +++ b/ietf/group/tests_review.py @@ -236,7 +236,7 @@ def test_reviewer_overview(self): r = self.client.get(url) self.assertEqual(r.status_code, 200) # We should see the new document with status of no response - self.assertContains(r, "No Response") + self.assertContains(r, "No response") self.assertContains(r, review_req1.doc.name) self.assertContains(r, review_req2.doc.name) # None of the reviews should be completed this time, diff --git a/ietf/templates/base.html b/ietf/templates/base.html index 9e07bad00d..1ccaf482dc 100644 --- a/ietf/templates/base.html +++ b/ietf/templates/base.html @@ -35,7 +35,7 @@ data-group-menu-data-url="{% url 'ietf.group.views.group_menu_data' %}"> {% analytical_body_top %} Skip to main content -