← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~sinzui/launchpad/licenses-0 into lp:launchpad

 

Curtis Hovey has proposed merging lp:~sinzui/launchpad/licenses-0 into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers): code


This is my branch to add the OFL and GFDL to the recognised licenses.

    lp:~sinzui/launchpad/licenses-0
    Diff size: 259
    Launchpad bug:
          https://bugs.launchpad.net/bugs/299734
          https://bugs.launchpad.net/bugs/616229
    Test command: ./bin/test -vv \
          -t product-widgets.txt -t test_project_licenses
    Pre-implementation: ~yosch
    Target release: 10.09


Add the OFL and GFDL to the recongnised licenses
------------------------------------------------

Add the OFL and GFDL licenses to the license enums and show them in the
second block of the license widget. We are doing OFL because Mark want it.
We postponed adding GFDL (no options) until after we had a license widget
that hide the rare licenses. We do, so this is a good time to add it.

Adding enums should be trivial. It is not. I was aware that the license widget
does odd things to make the licenses appear in AJAX enabled blocked. I added
an enum to learn what would break. The javascript and windmill tests both
broke because they assume that licenses 25 and 26 are the two special
licenses :(. I decided to fix the script. Then when I was done, I decided to
add the two licenses and be done quickly. Well it was not as quick as I hoped.


Rules
-----

    * Update the JS and windmill test to use the explicit other open source
      and other proprietary. Do not guess them by they number.
    * Add the enums.
    * Include them in the second block of the license widget.


QA
--

    * Visit https://staging.launchpad.net/launchpad/+edit
    * Verify you can see OFL and GFDL listed in the second block of licenses.


Lint
----

Linting changed files:
  lib/canonical/widgets/product.py
  lib/canonical/widgets/templates/license.pt
  lib/lp/registry/doc/product-widgets.txt
  lib/lp/registry/interfaces/product.py
  lib/lp/registry/windmill/tests/test_project_licenses.py


Test
----

    * lib/lp/registry/doc/product-widgets.txt
      * It was not obvious why adding two licenses change the order of several
        licenses. The answer is that the widget is creating an order for
        3 columns, and adding 2 licenses forces some licenses to the top of
        the next column :(
    * lib/lp/registry/windmill/tests/test_project_licenses.py
      * Updated the test to explicitly locate the OTHER_OPEN_SOURCE and
        OTHER_PROPRIETARY licenses...do not assume them by their number.


Implementation
--------------

    * lib/canonical/widgets/product.py
      * Added the OFL and GFDL to the "more" section of the widget. Fixed the
        dict spacing.
    * lib/canonical/widgets/templates/license.pt
      * Updated the script to locate the OTHER_OPEN_SOURCE and
        OTHER_PROPRIETARY licenses...do not assume them by their number.
    * lib/lp/registry/interfaces/product.py
      * Added the OFL and GFDL (no options) licenses to the enums.
-- 
https://code.launchpad.net/~sinzui/launchpad/licenses-0/+merge/33916
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~sinzui/launchpad/licenses-0 into lp:launchpad.
=== modified file 'lib/canonical/widgets/product.py'
--- lib/canonical/widgets/product.py	2010-08-12 19:55:29 +0000
+++ lib/canonical/widgets/product.py	2010-08-27 15:06:22 +0000
@@ -264,33 +264,35 @@
     allow_pending_license = False
 
     CATEGORIES = {
-        'AFFERO'        : 'recommended',
-        'APACHE'        : 'recommended',
-        'BSD'           : 'recommended',
-        'GNU_GPL_V2'    : 'recommended',
-        'GNU_GPL_V3'    : 'recommended',
-        'GNU_LGPL_V2_1' : 'recommended',
-        'GNU_LGPL_V3'   : 'recommended',
-        'MIT'           : 'recommended',
-        'CC_0'          : 'recommended',
-        'ACADEMIC'      : 'more',
-        'ARTISTIC'      : 'more',
-        'ARTISTIC_2_0'  : 'more',
-        'COMMON_PUBLIC' : 'more',
-        'ECLIPSE'       : 'more',
+        'AFFERO': 'recommended',
+        'APACHE': 'recommended',
+        'BSD': 'recommended',
+        'GNU_GPL_V2': 'recommended',
+        'GNU_GPL_V3': 'recommended',
+        'GNU_LGPL_V2_1': 'recommended',
+        'GNU_LGPL_V3': 'recommended',
+        'MIT': 'recommended',
+        'CC_0': 'recommended',
+        'ACADEMIC': 'more',
+        'ARTISTIC': 'more',
+        'ARTISTIC_2_0': 'more',
+        'COMMON_PUBLIC': 'more',
+        'ECLIPSE': 'more',
         'EDUCATIONAL_COMMUNITY': 'more',
-        'MPL'           : 'more',
-        'OPEN_SOFTWARE' : 'more',
-        'PHP'           : 'more',
-        'PUBLIC_DOMAIN' : 'more',
-        'PYTHON'        : 'more',
-        'ZPL'           : 'more',
-        'CC_BY'         : 'more',
-        'CC_BY_SA'      : 'more',
-        'PERL'          : 'deprecated',
-        'OTHER_PROPRIETARY' : 'special',
-        'OTHER_OPEN_SOURCE' : 'special',
-        'DONT_KNOW'     : 'special',
+        'GNU_GFDL_NO_OPTIONS': 'more',
+        'MPL': 'more',
+        'OFL': 'more',
+        'OPEN_SOFTWARE': 'more',
+        'PHP': 'more',
+        'PUBLIC_DOMAIN': 'more',
+        'PYTHON': 'more',
+        'ZPL': 'more',
+        'CC_BY': 'more',
+        'CC_BY_SA': 'more',
+        'PERL': 'deprecated',
+        'OTHER_PROPRIETARY': 'special',
+        'OTHER_OPEN_SOURCE': 'special',
+        'DONT_KNOW': 'special',
         }
 
     items_by_category = None

=== modified file 'lib/canonical/widgets/templates/license.pt'
--- lib/canonical/widgets/templates/license.pt	2010-08-10 20:02:08 +0000
+++ lib/canonical/widgets/templates/license.pt	2010-08-27 15:06:22 +0000
@@ -101,8 +101,8 @@
 
         // When Other/Proprietary or Other/Open Source is chosen, the
         // license_info widget is displayed.
-        var other_com = Y.get(Y.DOM.byId('field.licenses.25'));
-        var other_os = Y.get(Y.DOM.byId('field.licenses.26'));
+        var other_com = Y.get('input[value=OTHER_PROPRIETARY]');
+        var other_os = Y.get('input[value=OTHER_OPEN_SOURCE]');
         var details = Y.get('#license-details');
         var proprietary = Y.get('#proprietary');
 

=== modified file 'lib/lp/registry/doc/product-widgets.txt'
--- lib/lp/registry/doc/product-widgets.txt	2010-06-16 16:26:49 +0000
+++ lib/lp/registry/doc/product-widgets.txt	2010-08-27 15:06:22 +0000
@@ -250,7 +250,8 @@
     >>> license_widget = LicenseWidget(licenses_field, vtype, request)
 
 The widget has one checkbox for each license, and it also has a link to the
-license policy.  The licenses are split up into categories.
+license policy.  The licenses are split up into categories, and they are
+presented ordered to appear in a 3 column list.
 
     >>> from canonical.launchpad.testing.pages import find_tag_by_id
 
@@ -268,20 +269,23 @@
 
     >>> print extract_text(find_tag_by_id(html, 'more'))
     Academic Free License view license
-    Creative Commons - Attribution Share Alike view license
+    Eclipse Public License view license
     PHP License view license
     Artistic License 1.0 view license
-    Eclipse Public License view license
+    Educational Community License view license
     Public Domain view license
     Artistic License 2.0 view license
-    Educational Community License view license
+    GNU GFDL no options view license
     Python License view license
     Common Public License view license
     Mozilla Public License view license
     Zope Public License view license
     Creative Commons - Attribution view license
+    Open Font License v1.1 view license
+    Creative Commons - Attribution Share Alike view license
     Open Software License v 3.0 view license
 
+
     >>> print extract_text(find_tag_by_id(html, 'special'))
     I don't know yet
     Other/Proprietary
@@ -368,10 +372,10 @@
     ...
     [ ] Creative Commons - No Rights Reserved ...
     ...
+    [ ] Creative Commons - Attribution ...
+    ...
     [ ] Creative Commons - Attribution Share Alike ...
     ...
-    [ ] Creative Commons - Attribution ...
-    ...
 
 Any of the three Creative Commons licenses can be selected.
 
@@ -384,10 +388,10 @@
     ...
     [X] Creative Commons - No Rights Reserved ...
     ...
+    [X] Creative Commons - Attribution ...
+    ...
     [X] Creative Commons - Attribution Share Alike ...
     ...
-    [X] Creative Commons - Attribution ...
-    ...
 
 The BSD License can be selected.
 

=== modified file 'lib/lp/registry/interfaces/product.py'
--- lib/lp/registry/interfaces/product.py	2010-08-22 19:26:46 +0000
+++ lib/lp/registry/interfaces/product.py	2010-08-27 15:06:22 +0000
@@ -236,9 +236,10 @@
         'ACADEMIC', 'APACHE', 'ARTISTIC', 'ARTISTIC_2_0',
         'BSD', 'COMMON_PUBLIC',
         'CC_BY', 'CC_BY_SA', 'CC_0', 'ECLIPSE',
-        'EDUCATIONAL_COMMUNITY', 'AFFERO', 'GNU_GPL_V2', 'GNU_GPL_V3',
-        'GNU_LGPL_V2_1', 'GNU_LGPL_V3', 'MIT', 'MPL', 'OPEN_SOFTWARE', 'PERL',
-        'PHP', 'PUBLIC_DOMAIN', 'PYTHON', 'ZPL',
+        'EDUCATIONAL_COMMUNITY', 'AFFERO', 'GNU_GFDL_NO_OPTIONS',
+        'GNU_GPL_V2', 'GNU_GPL_V3', 'GNU_LGPL_V2_1', 'GNU_LGPL_V3', 'MIT',
+        'MPL', 'OFL', 'OPEN_SOFTWARE', 'PERL', 'PHP', 'PUBLIC_DOMAIN',
+        'PYTHON', 'ZPL',
         'DONT_KNOW', 'OTHER_PROPRIETARY', 'OTHER_OPEN_SOURCE')
 
     ACADEMIC = DBItem(
@@ -316,6 +317,12 @@
     CC_0 = DBItem(
         320, 'Creative Commons - No Rights Reserved',
         url='http://creativecommons.org/about/cc0')
+    GNU_GFDL_NO_OPTIONS = DBItem(
+        330, "GNU GFDL no options",
+        url='http://www.gnu.org/copyleft/fdl.html')
+    OFL = DBItem(
+        340, "Open Font License v1.1",
+        url='http://scripts.sil.org/OFL')
     # This is a placeholder "license" for users who know they want something
     # open source but haven't yet chosen a license for their project.  We do
     # not want to block them from registering their project, but this choice

=== modified file 'lib/lp/registry/windmill/tests/test_project_licenses.py'
--- lib/lp/registry/windmill/tests/test_project_licenses.py	2010-08-20 20:31:18 +0000
+++ lib/lp/registry/windmill/tests/test_project_licenses.py	2010-08-27 15:06:22 +0000
@@ -22,10 +22,9 @@
     def test_project_licenses(self):
         """Test the dynamic aspects of the project license picker."""
         # The firefox project is as good as any.
-        self.client.open(url=u'http://launchpad.dev:8085/firefox/+edit')
-        self.client.waits.forPageLoad(timeout=u'20000')
-
         lpuser.SAMPLE_PERSON.ensure_login(self.client)
+        self.client.open(url=u'http://launchpad.dev:8085/firefox/+edit')
+        self.client.waits.forPageLoad(timeout=u'20000')
 
         # The Recommended table is visible.
         self.client.waits.forElementProperty(
@@ -64,7 +63,7 @@
             option='className|lazr-closed')
 
         # But clicking on one of the Other/* licenses exposes it.
-        self.client.click(id='field.licenses.26')
+        self.client.click(xpath='//input[@value = "OTHER_OPEN_SOURCE"]')
         self.client.waits.forElementProperty(
             id=u'license-details',
             option='className|lazr-opened')
@@ -75,7 +74,7 @@
             id=u'proprietary',
             option='className|lazr-closed')
 
-        self.client.click(id='field.licenses.25')
+        self.client.click(xpath='//input[@value = "OTHER_PROPRIETARY"]')
         self.client.waits.forElementProperty(
             id=u'license-details',
             option='className|lazr-opened')
@@ -85,12 +84,12 @@
 
         # Only when all Other/* items are unchecked does the details box get
         # hidden.
-        self.client.click(id='field.licenses.26')
+        self.client.click(xpath='//input[@value = "OTHER_OPEN_SOURCE"]')
         self.client.waits.forElementProperty(
             id=u'license-details',
             option='className|lazr-opened')
 
-        self.client.click(id='field.licenses.25')
+        self.client.click(xpath='//input[@value = "OTHER_PROPRIETARY"]')
         self.client.waits.forElementProperty(
             id=u'license-details',
             option='className|lazr-closed')
@@ -101,17 +100,17 @@
         # Clicking on "I haven't specified..." unchecks everything and
         # closes the details box, but leaves the sections opened.
 
-        self.client.click(id='field.licenses.25')
+        self.client.click(xpath='//input[@value = "OTHER_PROPRIETARY"]')
         self.client.waits.forElementProperty(
             id=u'license-details',
             option='className|lazr-opened')
 
         self.client.asserts.assertChecked(
-            id=u'field.licenses.25')
+            xpath='//input[@value = "OTHER_PROPRIETARY"]')
 
         self.client.click(id='license_pending')
         self.client.asserts.assertNotChecked(
-            id=u'field.licenses.25')
+            xpath='//input[@value = "OTHER_PROPRIETARY"]')
 
         self.client.asserts.assertProperty(
             id=u'license-details',
@@ -121,7 +120,7 @@
         # time the page is visited, those sections will be open.  The
         # Recommended section is always open.
 
-        self.client.click(id='field.licenses.25')
+        self.client.click(xpath='//input[@value = "OTHER_PROPRIETARY"]')
         self.client.type(id='field.license_info', text='Foo bar')
         self.client.click(id='field.licenses.3')
         self.client.click(id='field.actions.change')