Merge lp://staging/~edwin-grubbs/launchpad/bug-568390-cyclic-membership-error into lp://staging/launchpad

Proposed by Edwin Grubbs
Status: Merged
Approved by: Paul Hummer
Approved revision: no longer in the source branch.
Merged at revision: 11110
Proposed branch: lp://staging/~edwin-grubbs/launchpad/bug-568390-cyclic-membership-error
Merge into: lp://staging/launchpad
Diff against target: 157 lines (+115/-7)
3 files modified
lib/lp/registry/browser/objectreassignment.py (+5/-6)
lib/lp/registry/browser/person.py (+27/-1)
lib/lp/registry/browser/tests/team-reassignment-view.txt (+83/-0)
To merge this branch: bzr merge lp://staging/~edwin-grubbs/launchpad/bug-568390-cyclic-membership-error
Reviewer Review Type Date Requested Status
Paul Hummer (community) code Approve
Review via email: mp+29407@code.staging.launchpad.net

Description of the change

Summary
-------

The TeamReassignmentView changes the owner of a team and then adds the
new owner as a member of that team. The view now disipays an error if
this creates a cyclical team membership, so that the model won't raise
an exception.

Implementation details
----------------------

The ObjectReassignmentView.isValidOwner() was not very flexible, since
it shouldn't be used to set a custom error message, so I changed it to
validateOwner(). This gets called at the end of
ObjectReassignmentView.validate(), after a new team has been created, if
the user is not using an existing team. isValidOwner() does not appear
to be used in any of the other subclasses of ObjectReassignmentView.

    lib/lp/registry/browser/objectreassignment.py
    lib/lp/registry/browser/person.py
    lib/lp/registry/browser/tests/team-reassignment-view.txt

Tests
-----

./bin/test -vv -t team-reassignment-view.txt

Demo and Q/A
------------

* Open https://launchpad.dev/people/+newteam
  * Create three new teams.
  * Add teams as members, so A is a member of B is a member of C.
  * Open https://launchpad.dev/~A/+reassign
    * Try to make C the owner of A.
    * It should display an error that this will cause a cyclical team
      membership.

To post a comment you must log in.
Revision history for this message
Paul Hummer (rockstar) wrote :

<rockstar> EdwinGrubbs, maybe validateOwner's abstract method should return False or raise NotImplementedError.
<EdwinGrubbs> rockstar: it's not required that validateOwner() be overridden. The vocabulary normally does a good enough job. This is the only subclass that actually does override it.
<EdwinGrubbs> so raising NotImplementedError isn't necessary, and returning false would be meaningless.
<rockstar> EdwinGrubbs, pass seems like it's very unopinionated
<EdwinGrubbs> rockstar: it's no different than LaunchpadFormView.validate().
<rockstar> EdwinGrubbs, okay.

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.