Merge lp://qastaging/~bac/launchpad/bug-32618 into lp://qastaging/launchpad

Proposed by Brad Crittenden
Status: Merged
Approved by: Curtis Hovey
Approved revision: no longer in the source branch.
Merged at revision: 11331
Proposed branch: lp://qastaging/~bac/launchpad/bug-32618
Merge into: lp://qastaging/launchpad
Diff against target: 320 lines (+91/-90)
5 files modified
lib/canonical/launchpad/utilities/gpghandler.py (+6/-6)
lib/lp/registry/browser/person.py (+42/-31)
lib/lp/registry/interfaces/jabber.py (+1/-2)
lib/lp/registry/stories/person/xx-person-edit-jabber-ids.txt (+29/-29)
lib/lp/registry/templates/person-editjabberids.pt (+13/-22)
To merge this branch: bzr merge lp://qastaging/~bac/launchpad/bug-32618
Reviewer Review Type Date Requested Status
Curtis Hovey (community) code Approve
Review via email: mp+32145@code.qastaging.launchpad.net

Commit message

Do not allow editing of jabberids in place. Convert to be a real LaunchpadFormView.

Description of the change

= Summary =

Multiple Jabberids can be edited in place with confusing results. The
UI is confusing. Simplifying the UI makes the problem impossible to
recreate.

== Proposed fix ==

Only display the jabberids, don't show them in editable fields. Need to
change a jabberid? Delete it and add it back correctly.

== Pre-implementation notes ==

Chit chat with Curtis.

== Implementation details ==

None

== Tests ==

bin/test -vvt xx-person-edit-jabber-ids.txt

== Demo and Q/A ==

http://launchpad.dev/~mark/+editjabberids

= Launchpad lint =

Will fix these.

Checking for conflicts and issues in changed files.

Linting changed files:
  lib/lp/registry/stories/person/xx-person-edit-jabber-ids.txt
  lib/lp/registry/templates/person-editjabberids.pt
  lib/lp/registry/browser/person.py

./lib/lp/registry/stories/person/xx-person-edit-jabber-ids.txt
       0: narrative uses a moin header.
       4: narrative uses a moin header.
      32: source exceeds 78 characters.
      45: narrative uses a moin header.

To post a comment you must log in.
Revision history for this message
Curtis Hovey (sinzui) wrote :

Hi Brad.

I love your proposed soltution that made this issue a trival problem. I see your editor converted a tab into a spaces :).

I have an optional request. I see that the save() method is doing validation /after/ it starts making changes to the jabber ids. I think we should move the validation code to a validate mthod and make the save() method only do changes. I see there are already tests showing the expected behaviour, and I expect this proposed refactoring to pass:

    def validate(self, data):
        jabberid = data.get('newjabberid')
        if jabberid is not None:
            jabberset = getUtility(IJabberIDSet)
            existingjabber = jabberset.getByJabberID(jabberid)
            if existingjabber.person != self.context:
                self.request.response.addErrorNotification(
                    structured(
                        'The Jabber ID %s is already registered by '
                        '<a href="%s">%s</a>.',
                        jabberid, canonical_url(existingjabber.person),
                        existingjabber.person.displayname))
            else:
                self.request.response.addErrorNotification(
                    'The Jabber ID %s already belongs to you.' % jabberid)
...
    @action(_("Save Changes"), name="save")
    def save(self, action, data):
...
        jabberid = form.get('newjabberid')
        if jabberid is not None:
            jabberset.new(self.context, jabberid)

review: Approve (code)
Revision history for this message
Brad Crittenden (bac) wrote :

Thanks for the comments, Curtis. I converted the form to be a proper LaunchpadFormView with the validation method. This also fixed bug 615872.

Incremental at http://pastebin.ubuntu.com/475950/

Revision history for this message
Curtis Hovey (sinzui) wrote :

I did not mean to cause any consternation. I really appreciate your fix to this old code and that this also addresses another bug.

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.