Hi Curtis, Thanks for the review and the test. I've attached the incremental diff. -Edwin > > === modified file 'lib/lp/registry/browser/person.py' > > --- lib/lp/registry/browser/person.py 2009-08-31 22:11:14 +0000 > > +++ lib/lp/registry/browser/person.py 2009-09-01 17:01:46 +0000 > > ... > > > +class PersonEditIRCNicknamesView(LaunchpadFormView): > > + > > + schema = Interface > > + > > + @property > > + def page_title(self): > > + return smartquote("%s's IRC nicknames" % self.context.displayname) > > + > > + label = page_title > > + > > + @property > > + def cancel_url(self): > > + return canonical_url(self.context) > > + > > + @action(_("Save Changes"), name="save") > > + def save(self, action, data): > > Can you report a bug and add an XXX that this form and action should > use schema and form validation? Done. > > +class PersonEditJabberIDsView(LaunchpadFormView): > > + schema = Interface > > + > > + @property > > + def page_title(self): > > + return smartquote("%s's Jabber IDs" % self.context.displayname) > > + > > + label = page_title > > + > > + @property > > + def cancel_url(self): > > + return canonical_url(self.context) > > + > > + @action(_("Save Changes"), name="save") > > + def save(self, action, data): > > """Process the Jabber ID form.""" > > Can you report a bug and add an XXX that this form and action should > use schema and form validation? Done. > > === modified file 'lib/lp/registry/stories/foaf/xx-person-edit-irc-ids.txt' > > --- lib/lp/registry/stories/foaf/xx-person-edit-irc-ids.txt 2009-08-13 > 15:12:16 +0000 > > +++ lib/lp/registry/stories/foaf/xx-person-edit-irc-ids.txt 2009-09-01 > 17:01:46 +0000 > > This whole test is bad. I would prefer to see this as a view test. If I send > you one will you consider replacing this test with it? > > > === modified file 'lib/lp/registry/templates/person-editircnicknames.pt' > > --- lib/lp/registry/templates/person-editircnicknames.pt 2009-08-13 > 15:12:16 +0000 > > +++ lib/lp/registry/templates/person-editircnicknames.pt 2009-09-01 > 15:51:26 +0000 > > @@ -6,26 +6,18 @@ > > xml:lang="en" > > lang="en" > > dir="ltr" > > Remove the xml:lang, lang, and dir because base-layout provides these. > > ... Done. Incremental diff: {{{ === modified file 'lib/lp/registry/browser/person.py' --- lib/lp/registry/browser/person.py 2009-09-01 17:01:46 +0000 +++ lib/lp/registry/browser/person.py 2009-09-01 19:32:40 +0000 @@ -3185,6 +3185,8 @@ @action(_("Save Changes"), name="save") def save(self, action, data): """Process the IRC nicknames form.""" + # XXX: EdwinGrubbs 2009-09-01 bug=422784 + # This view should use schema and form validation. form = self.request.form for ircnick in self.context.ircnicknames: # XXX: GuilhermeSalgado 2005-08-25: @@ -3232,6 +3234,8 @@ @action(_("Save Changes"), name="save") def save(self, action, data): """Process the Jabber ID form.""" + # XXX: EdwinGrubbs 2009-09-01 bug=422784 + # This view should use schema and form validation. form = self.request.form for jabber in self.context.jabberids: if form.get('remove_%s' % jabber.jabberid): === added file 'lib/lp/registry/doc/person-edit-views.txt' --- lib/lp/registry/doc/person-edit-views.txt 1970-01-01 00:00:00 +0000 +++ lib/lp/registry/doc/person-edit-views.txt 2009-09-01 20:20:31 +0000 @@ -0,0 +1,108 @@ +Person edit pages +================= + +There are many views to edit aspects of a user. + + +Edit IRC +-------- + +The +editircnickname provides a label and a title. + + >>> person = factory.makePerson(name='basil', displayname='Basil') + >>> login_person(person) + >>> view = create_initialized_view( + ... person, name='+editircnicknames', form={}, principal=person) + >>> print view.label + Basil's IRC nicknames + + >>> print view.page_title + Basil's IRC nicknames + + >>> print view.cancel_url + http://launchpad.dev/~basil + +The IRC form requires a nickname. + + >>> form = { + ... 'newnetwork': 'irc.freenode.net', + ... 'newnick': '', + ... 'field.actions.save': 'Save Changes', + ... } + >>> view = create_initialized_view( + ... person, name='+editircnicknames', form=form, principal=person) + + # This form does not use schema or LaunchpadFormView validation. + >>> view.errors + [] + + >>> for notification in view.request.response.notifications: + ... print notification.message + Neither Nickname nor Network can be empty... + + >>> [irc for irc in person.ircnicknames] + [] + +The IRC form requires a network. + + >>> form = { + ... 'newnetwork': '', + ... 'newnick': 'basil', + ... 'field.actions.save': 'Save Changes', + ... } + >>> view = create_initialized_view( + ... person, name='+editircnicknames', form=form, principal=person) + + # This form does not use schema or LaunchpadFormView validation. + >>> view.errors + [] + + >>> for notification in view.request.response.notifications: + ... print notification.message + Neither Nickname nor Network can be empty. + + >>> [irc for irc in person.ircnicknames] + [] + +The IRC nickname is added when both the nickname and network are submitted. + + >>> form = { + ... 'newnetwork': 'irc.freenode.net', + ... 'newnick': 'basil', + ... 'field.actions.save': 'Save Changes', + ... } + >>> view = create_initialized_view( + ... person, name='+editircnicknames', form=form, principal=person) + + # This form does not use schema or LaunchpadFormView validation. + >>> view.errors + [] + + >>> print view.request.response.notifications + [] + + >>> [ircnickname] = [irc for irc in person.ircnicknames] + >>> print ircnickname.nickname + basil + +An IRC nickname can be removed. + + >>> id = ircnickname.id + >>> form = { + ... 'newnetwork_%s' % ircnickname.id: 'irc.freenode.net', + ... 'newnick_%s' % ircnickname.id: 'basil', + ... 'remove_%s' % ircnickname.id: 'Remove', + ... 'field.actions.save': 'Save Changes', + ... } + >>> view = create_initialized_view( + ... person, name='+editircnicknames', form=form, principal=person) + + # This form does not use schema or LaunchpadFormView validation. + >>> view.errors + [] + + >>> print view.request.response.notifications + [] + + >>> [irc.nickname for irc in person.ircnicknames] + [] \ No newline at end of file === removed file 'lib/lp/registry/stories/foaf/xx-person-edit-irc-ids.txt' --- lib/lp/registry/stories/foaf/xx-person-edit-irc-ids.txt 2009-09-01 17:01:46 +0000 +++ lib/lp/registry/stories/foaf/xx-person-edit-irc-ids.txt 1970-01-01 00:00:00 +0000 @@ -1,54 +0,0 @@ - Try to add a new ircid with an empty nickname. - - - >>> print http(r""" - ... POST /~name16/+editircnicknames HTTP/1.1 - ... Authorization: Basic Zm9vLmJhckBjYW5vbmljYWwuY29tOnRlc3Q= - ... Content-Type: application/x-www-form-urlencoded - ... - ... newnetwork=irc.freenode.net&newnick=&field.actions.save=Save+Changes""") - HTTP/1.1 200 Ok - ... - ...Neither Nickname nor Network can be empty... - ... - - - Now try to add a new one with an empty network. - - >>> print http(r""" - ... POST /~name16/+editircnicknames HTTP/1.1 - ... Authorization: Basic Zm9vLmJhckBjYW5vbmljYWwuY29tOnRlc3Q= - ... Content-Type: application/x-www-form-urlencoded - ... - ... newnetwork=&newnick=mark&field.actions.save=Save+Changes""") - HTTP/1.1 200 Ok - ... - ...Neither Nickname nor Network can be empty... - - - Now do it properly, with a non-empty nickname and network. - - >>> print http(r""" - ... POST /~name16/+editircnicknames HTTP/1.1 - ... Authorization: Basic Zm9vLmJhckBjYW5vbmljYWwuY29tOnRlc3Q= - ... Content-Type: application/x-www-form-urlencoded - ... - ... newnetwork=irc.freenode.net&newnick=mark&field.actions.save=Save+Changes""") - HTTP/1.1 200 Ok - ... - ...IRC nicknames... - ...value="irc.freenode.net"... - ...value="mark"... - ... - - - And now, remove it. - - >>> print http(r""" - ... POST /~name16/+editircnicknames HTTP/1.1 - ... Authorization: Basic Zm9vLmJhckBjYW5vbmljYWwuY29tOnRlc3Q= - ... Content-Type: application/x-www-form-urlencoded - ... - ... network_11=irc.freenode.net&nick_11=mark&remove_11=Remove&newnetwork=&newnick=&field.actions.save=Save+Changes""") - HTTP/1.1 200 Ok - ... === modified file 'lib/lp/registry/templates/person-editircnicknames.pt' --- lib/lp/registry/templates/person-editircnicknames.pt 2009-09-01 15:51:26 +0000 +++ lib/lp/registry/templates/person-editircnicknames.pt 2009-09-01 19:33:42 +0000 @@ -3,9 +3,6 @@ xmlns:tal="http://xml.zope.org/namespaces/tal" xmlns:metal="http://xml.zope.org/namespaces/metal" xmlns:i18n="http://xml.zope.org/namespaces/i18n" - xml:lang="en" - lang="en" - dir="ltr" metal:use-macro="view/macro:page/main_only" i18n:domain="launchpad" > === modified file 'lib/lp/registry/templates/person-editjabberids.pt' --- lib/lp/registry/templates/person-editjabberids.pt 2009-09-01 16:24:26 +0000 +++ lib/lp/registry/templates/person-editjabberids.pt 2009-09-01 19:20:46 +0000 @@ -3,9 +3,6 @@ xmlns:tal="http://xml.zope.org/namespaces/tal" xmlns:metal="http://xml.zope.org/namespaces/metal" xmlns:i18n="http://xml.zope.org/namespaces/i18n" - xml:lang="en" - lang="en" - dir="ltr" metal:use-macro="view/macro:page/main_only" i18n:domain="launchpad" > @@ -18,10 +15,8 @@
-

Existing Jabber IDs

- - + @@ -42,12 +37,8 @@
- -

New Jabber ID

- - - - + + === modified file 'lib/lp/registry/templates/person-editlocation.pt' --- lib/lp/registry/templates/person-editlocation.pt 2009-09-01 17:01:46 +0000 +++ lib/lp/registry/templates/person-editlocation.pt 2009-09-01 19:33:17 +0000 @@ -3,9 +3,6 @@ xmlns:tal="http://xml.zope.org/namespaces/tal" xmlns:metal="http://xml.zope.org/namespaces/metal" xmlns:i18n="http://xml.zope.org/namespaces/i18n" - xml:lang="en" - lang="en" - dir="ltr" metal:use-macro="view/macro:page/main_only" i18n:domain="launchpad"> }}}