From 550c1233fea24e5cbdbe998dd1c850e172729ef7 Mon Sep 17 00:00:00 2001
From: Robert Sparks <rjsparks@nostrum.com>
Date: Wed, 3 Mar 2021 20:15:57 +0000
Subject: [PATCH] Change ipr pages to say General rather than Generic, and to
 change the text to note email submissions are not accepted. Fixes #3209.
 Commit ready for merge.  - Legacy-Id: 18886

---
 ietf/ipr/forms.py                    |  2 +-
 ietf/ipr/tests.py                    | 14 +++++++++++---
 ietf/ipr/urls.py                     |  2 +-
 ietf/ipr/views.py                    | 12 ++++++++++++
 ietf/templates/ipr/details_edit.html | 21 +++++++++++++++------
 ietf/templates/ipr/disclosure.html   |  2 +-
 ietf/templates/ipr/list.html         |  4 ++--
 7 files changed, 43 insertions(+), 14 deletions(-)

diff --git a/ietf/ipr/forms.py b/ietf/ipr/forms.py
index 1d8bcc047..792128592 100644
--- a/ietf/ipr/forms.py
+++ b/ietf/ipr/forms.py
@@ -233,7 +233,7 @@ class GenericDisclosureForm(forms.Form):
             for k in patent_fields:
                 if not cleaned_data.get(k):
                     self.add_error(k, "This field is required if you are filing a patent-specific disclosure.")
-            raise forms.ValidationError("A generic IPR disclosure cannot have any patent-specific information, "
+            raise forms.ValidationError("A general IPR disclosure cannot have any patent-specific information, "
                                         "but a patent-specific disclosure must provide full patent information.")
 
         patent_fields += ['patent_notes']
diff --git a/ietf/ipr/tests.py b/ietf/ipr/tests.py
index 07c0eec1f..12f587d0f 100644
--- a/ietf/ipr/tests.py
+++ b/ietf/ipr/tests.py
@@ -6,7 +6,7 @@ import datetime
 
 
 from pyquery import PyQuery
-from urllib.parse import quote
+from urllib.parse import quote, urlparse
 
 from django.urls import reverse as urlreverse
 
@@ -208,9 +208,17 @@ class IprTests(TestCase):
         self.assertContains(r, "/ipr/%s/" % ipr.pk)
 
     def test_new_generic(self):
-        """Add a new generic disclosure.  Note: submitter does not need to be logged in.
-        """
+        """Ensure new-generic redirects to new-general"""
         url = urlreverse("ietf.ipr.views.new", kwargs={ "type": "generic" })
+        r = self.client.get(url)
+        self.assertEqual(r.status_code,302)
+        self.assertEqual(urlparse(r["Location"]).path, urlreverse("ietf.ipr.views.new", kwargs={ "type": "general"}))
+
+
+    def test_new_general(self):
+        """Add a new general disclosure.  Note: submitter does not need to be logged in.
+        """
+        url = urlreverse("ietf.ipr.views.new", kwargs={ "type": "general" })
 
         # invalid post
         r = self.client.post(url, {
diff --git a/ietf/ipr/urls.py b/ietf/ipr/urls.py
index 476a9f6a7..6f7b2d408 100644
--- a/ietf/ipr/urls.py
+++ b/ietf/ipr/urls.py
@@ -25,6 +25,6 @@ urlpatterns = [
     url(r'^(?P<id>\d+)/state/$', views.state),
     url(r'^update/$', RedirectView.as_view(url=reverse_lazy('ietf.ipr.views.showlist'), permanent=True)),
     url(r'^update/(?P<id>\d+)/$', views.update),
-    url(r'^new-(?P<type>(specific|generic|third-party))/$', views.new),
+    url(r'^new-(?P<type>(specific|generic|general|third-party))/$', views.new),
     url(r'^search/$', views.search),
 ]
diff --git a/ietf/ipr/views.py b/ietf/ipr/views.py
index f5de45274..88e6db45a 100644
--- a/ietf/ipr/views.py
+++ b/ietf/ipr/views.py
@@ -484,6 +484,18 @@ def by_draft_recursive_txt(request):
 def new(request, type, updates=None):
     """Submit a new IPR Disclosure.  If the updates field != None, this disclosure
     updates one or more other disclosures."""
+    # Note that URL patterns won't ever send updates - updates is only non-null when called from code
+
+    # This odd construct flipping generic and general allows the URLs to say 'general' while having a minimal impact on the code.
+    # A cleanup to change the code to switch on type 'general' should follow.
+    if type == 'generic' and updates: # Only happens when called directly from the updates view
+        pass
+    elif type == 'generic':
+        return HttpResponseRedirect(urlreverse('ietf.ipr.views.new',kwargs=dict(type='general')))
+    elif type == 'general':
+        type = 'generic'
+    else:
+        pass
 
     # 1 to show initially + the template
     DraftFormset = inlineformset_factory(IprDisclosureBase, IprDocRel, form=DraftForm, can_delete=False, extra=1 + 1)
diff --git a/ietf/templates/ipr/details_edit.html b/ietf/templates/ipr/details_edit.html
index 53522b140..e610a4c6f 100644
--- a/ietf/templates/ipr/details_edit.html
+++ b/ietf/templates/ipr/details_edit.html
@@ -37,7 +37,7 @@
       patent applicants.</p>
 
   {% else %}
-    <h1>The Patent Disclosure and Licensing Declaration Template for Generic IPR Disclosures</h1>
+    <h1>The Patent Disclosure and Licensing Declaration Template for General IPR Disclosures</h1>
     <p>This document is an IETF IPR Patent Disclosure and Licensing
       Declaration Template and is submitted to inform the IETF of a) patent
       or patent application information that is not related to a specific
@@ -49,18 +49,27 @@
       <a href="https://www.ietf.org/rfc/rfc8179.txt">RFC 8179</a>,
       "Intellectual Property Rights in IETF Technology," you
       are still required to file specific disclosures on IPR unless your
-      generic disclosure satisfies certain conditions. Please see the
+      general disclosure satisfies certain conditions. Please see the
       RFC for details.</p>
   {% endif %}
 
   <p>
-    If you wish to submit your IPR disclosure by e-mail, then please send
-    it to <a href="mailto:ietf-ipr@ietf.org">ietf-ipr@ietf.org</a>.
-    Submissions made by e-mail that do not comply with the formal
+    Submissions that do not comply with the formal
     requirements of Section 5, "IPR Disclosures," of
     <a href="https://www.ietf.org/rfc/rfc8179.txt">RFC 8179</a>,
     "Intellectual Property Rights in IETF Technology",
-    will be posted, but will be marked as "non-compliant".
+    may be 
+    {% if form.instance|to_class_name != "GenericIprDisclosure" %}
+      rejected or may be published as general disclosures.
+    {% else %}
+      rejected.
+    {% endif %}
+  </p>
+
+  <p>
+    If you have any questions or problems with form then please contact
+    <a href="mailto:ietf-ipr@ietf.org">ietf-ipr@ietf.org</a>. We do not
+    accept IPR disclosures by email.
   </p>
 
 
diff --git a/ietf/templates/ipr/disclosure.html b/ietf/templates/ipr/disclosure.html
index 127fcab28..d1d3bd0d9 100644
--- a/ietf/templates/ipr/disclosure.html
+++ b/ietf/templates/ipr/disclosure.html
@@ -12,7 +12,7 @@
 
   <ul>
     <li><a href="{% url "ietf.ipr.views.new" "specific" %}">File a disclosure about your IPR related to a specific IETF contribution</a></li>
-    <li><a href="{% url "ietf.ipr.views.new" "generic" %}">File an IPR disclosure that is not related to a specific IETF contribution</a></li>
+    <li><a href="{% url "ietf.ipr.views.new" "general" %}">File an IPR disclosure that is not related to a specific IETF contribution</a></li>
     <li><a href="{% url "ietf.ipr.views.new" "third-party" %}">Notify the IETF of IPR other than your own</a></li>
     <li>To update an existing IPR disclosure, find the original disclosure and select "update this IPR disclosure".</li>
     <li><a href="{% url "ietf.ipr.views.search" %}">Search the IPR disclosures</a></li>
diff --git a/ietf/templates/ipr/list.html b/ietf/templates/ipr/list.html
index de3a54652..a79e2cc4b 100644
--- a/ietf/templates/ipr/list.html
+++ b/ietf/templates/ipr/list.html
@@ -33,7 +33,7 @@
         {% endif %}
       </p>
 
-      <h2 class="anchor-target" id="generic">Generic IPR disclosures</h2>
+      <h2 class="anchor-target" id="generic">General IPR disclosures</h2>
 
       {% include "ipr/ipr_table.html" with iprs=generic_disclosures %}
 
@@ -49,7 +49,7 @@
 
     <div class="col-md-2 hidden-print bs-docs-sidebar" id="affix">
       <ul class="nav nav-pills nav-stacked small" data-spy="affix">
-        <li><a href="#generic">Generic IPR disclosures</a></li>
+        <li><a href="#generic">General IPR disclosures</a></li>
         <li><a href="#specific">Specific IPR disclosures</a></li>
         <li><a href="#notify">Specific third-party IPR disclosures</a></li>
       </ul>