← Back to team overview

launchpad-reviewers team mailing list archive

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

 

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

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #997346 in Launchpad itself: "Double complimentary commercial subscription notification when projects changes from an open source license to an proprietary one"
  https://bugs.launchpad.net/launchpad/+bug/997346

For more details, see:
https://code.launchpad.net/~sinzui/launchpad/licenses-modified/+merge/107229

Pre-implementation: flacoste

When an existing project uses Change details to add a proprietary
license, The maintainer is notified once because the licenses change,
and then again because the form was used to change the project. The
ObjectModifiedEvent event is created twice, which in turn calls the single
subscriber to IObjectModifiedEvent event twice.

--------------------------------------------------------------------

RULES

    * Create a specific kind of event that is only created by the
      _setLicenses() method and subscribe the notify function to it.
    * Subclass the ObjectModifiedEvent and implemented a unique interface.
      * Do not use edited_fields because few callsites populate it
        properly. Francis advises not supporting it.
    * Subscribe the notify function to the new interface.
    * Update the model (which is used by both UI and API) to notify
      the new event. It will be the only callsite for the event in
      any request.


QA

    * Visit https://qastaging.launchpad.net/projects/+new
    * Register a new project and choose the MIT license.
    * Choose Change details
    * Add the proprietary license.
    * Verify only one notification is shown.


LINT

    lib/lp/registry/configure.zcml
    lib/lp/registry/subscribers.py
    lib/lp/registry/interfaces/product.py
    lib/lp/registry/model/product.py
    lib/lp/registry/tests/test_subscribers.py


TEST

    ./bin/test -vvc lp.registry.tests.test_subscribers


IMPLEMENTATION

Created LicensesModifiedEvent which has a unique interface for license
events. The class ignores the edited_fields and object_before_modification,
but they are provided for the parent class. Updated _setLicenses() to
use the new event.
    lib/lp/registry/interfaces/product.py
    lib/lp/registry/model/product.py
    lib/lp/registry/tests/test_subscribers.py

Subscribed product_licenses_modified to the ILicensesModifiedEvent. Removed
the codes that was needed to work with the generic event.
    lib/lp/registry/configure.zcml
    lib/lp/registry/subscribers.py
    lib/lp/registry/tests/test_subscribers.py
-- 
https://code.launchpad.net/~sinzui/launchpad/licenses-modified/+merge/107229
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~sinzui/launchpad/licenses-modified into lp:launchpad.


Follow ups