Merge lp:~bac/launchpad/bug-186660 into lp:launchpad

Proposed by Brad Crittenden
Status: Merged
Approved by: Gary Poster
Approved revision: no longer in the source branch.
Merged at revision: 13147
Proposed branch: lp:~bac/launchpad/bug-186660
Merge into: lp:launchpad
Diff against target: 530 lines (+2/-415)
7 files modified
lib/canonical/launchpad/pagetests/basics/notfound-traversals.txt (+0/-1)
lib/lp/registry/browser/configure.zcml (+0/-6)
lib/lp/registry/browser/person.py (+2/-182)
lib/lp/registry/stories/person/xx-person-edit-wikis.txt (+0/-134)
lib/lp/registry/templates/person-editwikinames.pt (+0/-75)
lib/lp/registry/templates/person-portlet-contact-details.pt (+0/-15)
lib/lp/registry/templates/product-rdf.pt (+0/-2)
To merge this branch: bzr merge lp:~bac/launchpad/bug-186660
Reviewer Review Type Date Requested Status
Gary Poster (community) Approve
Review via email: mp+63029@code.launchpad.net

Commit message

[r=gary][bug=186660] Remove Person wiki_names from web UI.

Description of the change

= Summary =

It has been determined (see the bug discussion) that wiki_names are not
a useful thing to be associated with a Person in Launchpad.

== Proposed fix ==

This branch removes the wiki names from the web UI.

Subsequent branches will remove wiki_names from the webservice (while
attempting to maintain backwards compatibility) and another branch
removes them from the database.

== Pre-implementation notes ==

Chats with Gary.

== Implementation details ==

As above.

== Tests ==

None, as the test has been removed.

== Demo and Q/A ==

Visit http://launchpad.dev/~name12 and see that the wiki name is not
shown. Visit http://launchpad.dev/~name12/+editwikinames
= Launchpad lint =

Checking for conflicts and issues in changed files.

Linting changed files:
  lib/lp/registry/browser/configure.zcml
  lib/canonical/launchpad/pagetests/basics/notfound-traversals.txt
  lib/lp/registry/templates/product-rdf.pt
  lib/lp/registry/templates/person-portlet-contact-details.pt
  lib/lp/registry/browser/person.py

./lib/canonical/launchpad/pagetests/basics/notfound-traversals.txt
   Lots of known, annoying lint.

To post a comment you must log in.
Revision history for this message
Gary Poster (gary) wrote :

Looks good. Thank you.

Highlights from IRC discussion:

 * you have another branch coming that handles making the webservice backwards compatible
 * You could maybe not move the CoC over to the next column, because it already looked similar if you did not have a wiki page set and people might be used to looking in the current location, but do as you think best.

Gary

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/canonical/launchpad/pagetests/basics/notfound-traversals.txt'
2--- lib/canonical/launchpad/pagetests/basics/notfound-traversals.txt 2011-05-13 03:46:29 +0000
3+++ lib/canonical/launchpad/pagetests/basics/notfound-traversals.txt 2011-06-01 12:33:35 +0000
4@@ -388,7 +388,6 @@
5 >>> check("/~name16/+related-software")
6 >>> check("/~name16/+editsshkeys", auth=True)
7 >>> check("/~name16/+editpgpkeys", auth=True)
8->>> check("/~name16/+editwikinames", auth=True)
9 >>> check("/~name16/+editjabberids", auth=True)
10 >>> check("/~name16/+codesofconduct", auth=True)
11 >>> check("/~name16/+edithomepage", auth=True)
12
13=== modified file 'lib/lp/registry/browser/configure.zcml'
14--- lib/lp/registry/browser/configure.zcml 2011-05-27 21:03:22 +0000
15+++ lib/lp/registry/browser/configure.zcml 2011-06-01 12:33:35 +0000
16@@ -1040,12 +1040,6 @@
17 class="lp.registry.browser.person.PersonCodeOfConductEditView"
18 template="../templates/person-codesofconduct.pt"/>
19 <browser:page
20- name="+editwikinames"
21- for="lp.registry.interfaces.person.IPerson"
22- permission="launchpad.Edit"
23- class="lp.registry.browser.person.PersonEditWikiNamesView"
24- template="../templates/person-editwikinames.pt"/>
25- <browser:page
26 name="+editircnicknames"
27 for="lp.registry.interfaces.person.IPerson"
28 permission="launchpad.Edit"
29
30=== modified file 'lib/lp/registry/browser/person.py'
31--- lib/lp/registry/browser/person.py 2011-05-27 21:12:25 +0000
32+++ lib/lp/registry/browser/person.py 2011-06-01 12:33:35 +0000
33@@ -28,7 +28,6 @@
34 'PersonEditLocationView',
35 'PersonEditSSHKeysView',
36 'PersonEditView',
37- 'PersonEditWikiNamesView',
38 'PersonFacets',
39 'PersonGPGView',
40 'PersonIndexMenu',
41@@ -100,10 +99,7 @@
42 from lazr.delegates import delegates
43 from lazr.restful.interface import copy_field
44 from lazr.restful.interfaces import IWebServiceClientRequest
45-from lazr.uri import (
46- InvalidURIError,
47- URI,
48- )
49+from lazr.uri import URI
50 import pytz
51 from storm.expr import Join
52 from storm.zope.interfaces import IResultSet
53@@ -228,7 +224,6 @@
54 )
55 from lp.app.widgets.location import LocationWidget
56 from lp.app.widgets.password import PasswordChangeWidget
57-from lp.app.widgets.textwidgets import URIWidget
58 from lp.blueprints.browser.specificationtarget import HasSpecificationsView
59 from lp.blueprints.enums import SpecificationFilter
60 from lp.bugs.browser.bugtask import BugTaskSearchListingView
61@@ -297,10 +292,7 @@
62 ITeamMembershipSet,
63 TeamMembershipStatus,
64 )
65-from lp.registry.interfaces.wikiname import (
66- IWikiName,
67- IWikiNameSet,
68- )
69+from lp.registry.interfaces.wikiname import IWikiNameSet
70 from lp.registry.mail.notification import send_direct_contact_email
71 from lp.registry.model.milestone import (
72 Milestone,
73@@ -1054,7 +1046,6 @@
74 'common_edithomepage',
75 'editemailaddresses',
76 'editlanguages',
77- 'editwikinames',
78 'editircnicknames',
79 'editjabberids',
80 'editsshkeys',
81@@ -1104,12 +1095,6 @@
82 return Link(target, text, icon='edit')
83
84 @enabled_with_permission('launchpad.Edit')
85- def editwikinames(self):
86- target = '+editwikinames'
87- text = 'Update wiki names'
88- return Link(target, text, icon='edit')
89-
90- @enabled_with_permission('launchpad.Edit')
91 def editircnicknames(self):
92 target = '+editircnicknames'
93 text = 'Update IRC nicknames'
94@@ -2789,16 +2774,6 @@
95 check_permission('launchpad.Edit', self.context))
96
97 @property
98- def should_show_wikinames_section(self):
99- """Should the 'Wiki names' section be shown?
100-
101- It's shown when the person has Wiki names registered or has rights
102- to register new ones.
103- """
104- return not self.context.wiki_names.is_empty() or (
105- check_permission('launchpad.Edit', self.context))
106-
107- @property
108 def should_show_jabberids_section(self):
109 """Should the 'Jabber IDs' section be shown?
110
111@@ -3560,161 +3535,6 @@
112 sCoC_util.modifySignature(sig_id, self.user, comment, False)
113
114
115-class PersonEditWikiNamesView(LaunchpadFormView):
116- """View for ~person/+editwikinames"""
117-
118- schema = IWikiName
119- fields = ['wiki', 'wikiname']
120- # Use custom widgets solely to get the width correct. The URIWidget has a
121- # CSS class that does not respect the displayWidth, thus the need to use a
122- # different cssClass.
123- custom_widget('wiki', URIWidget, displayWidth=40, cssClass="textType")
124- custom_widget('wikiname', TextWidget, displayWidth=40)
125-
126- @property
127- def label(self):
128- return smartquote("%s's wiki names" % self.context.displayname)
129-
130- @property
131- def next_url(self):
132- return canonical_url(self.context)
133-
134- cancel_url = next_url
135-
136- def setUpFields(self):
137- super(PersonEditWikiNamesView, self).setUpFields()
138- if self.context.wiki_names.count() > 0:
139- # Make the wiki and wiki_name entries optional on the edit page if
140- # one or more ids already exist, which allows the removal of ids
141- # without filling out the new wiki fields.
142- wiki_field = self.form_fields['wiki']
143- wikiname_field = self.form_fields['wikiname']
144- # Copy the fields so as not to modify the interface.
145- wiki_field.field = copy_field(wiki_field.field)
146- wiki_field.field.required = False
147- wikiname_field.field = copy_field(wikiname_field.field)
148- wikiname_field.field.required = False
149-
150- def _validateWikiURL(self, url):
151- """Validate the URL.
152-
153- Make sure that the result is a valid URL with only the
154- appropriate schemes. The url is assumed to be a string.
155- """
156- if url is None:
157- return
158- try:
159- uri = URI(url)
160- if uri.scheme not in ('http', 'https'):
161- self.setFieldError(
162- 'wiki',
163- structured(
164- 'The URL scheme "%(scheme)s" is not allowed. '
165- 'Only http or https URLs may be used.',
166- scheme=uri.scheme))
167- except InvalidURIError:
168- self.setFieldError(
169- 'wiki',
170- structured(
171- '"%(url)s" is not a valid URL.', url=url))
172-
173- def _validateWikiName(self, name):
174- """Ensure the wikiname is valid.
175-
176- It must not be longer than 100 characters. Name is assumed to be a
177- string.
178- """
179- max_len = 100
180- if len(name) > max_len:
181- self.setFieldError(
182- 'wikiname',
183- structured(
184- 'The wiki name cannot exceed %d characters.' % max_len))
185-
186- def _sanitizeWikiURL(self, url):
187- """Strip whitespaces and make sure :url ends in a single '/'."""
188- if not url:
189- return url
190- return '%s/' % url.strip().rstrip('/')
191-
192- def validate(self, data):
193- # If there are already form errors then just show them.
194- if self.errors:
195- return
196- wikiurl = self._sanitizeWikiURL(data.get('wiki'))
197- wikiname = data.get('wikiname')
198- if wikiurl or wikiname:
199- if not wikiurl:
200- self.setFieldError(
201- 'wiki',
202- structured(
203- 'The Wiki URL must be specified.'))
204- if not wikiname:
205- self.setFieldError(
206- 'wikiname',
207- structured(
208- 'The Wiki name must be specified.'))
209-
210- if self.errors:
211- return
212-
213- if wikiurl is not None:
214- self._validateWikiURL(wikiurl)
215- if wikiname is not None:
216- self._validateWikiName(wikiname)
217-
218- if self.errors:
219- return
220-
221- wikinameset = getUtility(IWikiNameSet)
222- existingwiki = wikinameset.getByWikiAndName(wikiurl, wikiname)
223- if existingwiki:
224- if existingwiki.person != self.context:
225- owner_name = urllib.quote(existingwiki.person.name)
226- merge_url = (
227- '%s/+requestmerge?field.dupe_person=%s'
228- % (canonical_url(getUtility(IPersonSet)), owner_name))
229- self.setFieldError(
230- 'wikiname',
231- structured(
232- 'The WikiName %s%s is already registered by '
233- '<a href="%s">%s</a>. If you think this is a '
234- 'duplicated account, you can <a href="%s">merge it'
235- '</a> into your account.',
236- wikiurl, wikiname,
237- canonical_url(existingwiki.person),
238- existingwiki.person.displayname, merge_url))
239- else:
240- # The person already has this wiki.
241- self.setFieldError(
242- 'wikiname',
243- 'The WikiName %s%s already belongs to you.' %
244- (wikiurl, wikiname))
245-
246- def _save(self, wikiurl, wikiname):
247- """Given a wikiurl and wikiname, attempt to save it.
248-
249- Verify someone else doesn't have it already.
250- """
251-
252- @action(_("Save Changes"), name="save")
253- def save(self, action, data):
254- """Process the wiki names form."""
255- form = self.request.form
256- for obj in self.context.wiki_names:
257- if form.get('remove_%s' % obj.id):
258- obj.destroySelf()
259-
260- if not self.errors:
261- wikiurl = self._sanitizeWikiURL(data.get('wiki'))
262- wikiname = data.get('wikiname')
263- # If either url or name are present then they both must be
264- # entered.
265- if wikiurl and wikiname:
266- wikinameset = getUtility(IWikiNameSet)
267- wikinameset.new(self.context, wikiurl, wikiname)
268-
269-
270 class PersonEditIRCNicknamesView(LaunchpadFormView):
271
272 schema = Interface
273
274=== removed file 'lib/lp/registry/stories/person/xx-person-edit-wikis.txt'
275--- lib/lp/registry/stories/person/xx-person-edit-wikis.txt 2010-08-31 14:00:54 +0000
276+++ lib/lp/registry/stories/person/xx-person-edit-wikis.txt 1970-01-01 00:00:00 +0000
277@@ -1,134 +0,0 @@
278-Person's wikinames
279-==================
280-
281-A person can have any number of WikiNames registered in Launchpad, and
282-they can be managed on the +editwikinames page.
283-
284- # A helper function for printing all wikinames of a person.
285- >>> def print_existing_wikiurls(contents):
286- ... trs = find_tags_by_class(contents, 'wikiurl')
287- ... wikis = []
288- ... for tr in trs:
289- ... td = tr.find('td')
290- ... wikis.append(td.contents[0])
291- ... print '\n'.join(wikis)
292-
293- >>> def print_feedback(browser):
294- ... print "\n".join(get_feedback_messages(browser.contents))
295-
296-Mark already has one WikiName registered.
297-
298- >>> browser.addHeader('Authorization', 'Basic mark@example.com:test')
299- >>> browser.open('http://launchpad.dev/~mark/+editwikinames')
300- >>> print_existing_wikiurls(browser.contents)
301- https://wiki.ubuntu.com/MarkShuttleworth
302-
303-But he wants to register another one.
304-
305- >>> browser.getControl(name='field.wiki').value = 'http://foo.bar/wiki/'
306- >>> browser.getControl(name='field.wikiname').value = 'FooBar'
307- >>> browser.getControl('Save Changes').click()
308- >>> print_feedback(browser)
309- >>> print browser.url
310- http://launchpad.dev/~mark
311- >>> browser.open('http://launchpad.dev/~mark/+editwikinames')
312- >>> print_existing_wikiurls(browser.contents)
313- http://foo.bar/wiki/FooBar
314- https://wiki.ubuntu.com/MarkShuttleworth
315-
316-He can't have two identical wiki names, though.
317-
318- >>> browser.getControl(name='field.wiki').value = 'http://foo.bar/wiki/'
319- >>> browser.getControl(name='field.wikiname').value = 'FooBar'
320- >>> browser.getControl('Save Changes').click()
321- >>> print browser.url
322- http://launchpad.dev/%7Emark/+editwikinames
323- >>> for message in find_tags_by_class(browser.contents, 'message'):
324- ... print message.renderContents()
325- There is 1 error.
326- The WikiName http://foo.bar/wiki/FooBar already belongs to you.
327-
328-Nor can he have a WikiName that is already registered in Launchpad.
329-
330- >>> browser.getControl(name='field.wiki').value = (
331- ... 'https://wiki.ubuntu.com/')
332- >>> browser.getControl(name='field.wikiname').value = 'GuilhermeSalgado'
333- >>> browser.getControl('Save Changes').click()
334- >>> print browser.url
335- http://launchpad.dev/%7Emark/+editwikinames
336- >>> print "\n".join(get_feedback_messages(browser.contents))
337- There is 1 error.
338- The WikiName https://wiki.ubuntu.com/GuilhermeSalgado is already
339- registered by Guilherme Salgado. If you think this is a duplicated
340- account, you can merge it into your account.
341-
342-A WikiName's URL can't be empty nor invalid.
343-
344- >>> browser.getControl(name='field.wiki').value = ''
345- >>> browser.getControl(name='field.wikiname').value = 'FooBar'
346- >>> browser.getControl('Save Changes').click()
347- >>> print browser.url
348- http://launchpad.dev/%7Emark/+editwikinames
349- >>> print "\n".join(get_feedback_messages(browser.contents))
350- There is 1 error.
351- The Wiki URL must be specified.
352-
353- >>> browser.getControl(name='field.wiki').value = '/this-is-not-a-url/'
354- >>> browser.getControl(name='field.wikiname').value = 'FooBar'
355- >>> browser.getControl('Save Changes').click()
356- >>> print browser.url
357- http://launchpad.dev/%7Emark/+editwikinames
358- >>> print "\n".join(get_feedback_messages(browser.contents))
359- There is 1 error.
360- "/this-is-not-a-url/" is not a valid URI
361-
362-And it can't be incredibly long.
363-
364- >>> browser.getControl(name='field.wiki').value = (
365- ... 'https://wiki.ubuntu.com/')
366- >>> wikiname = "z" * 101
367- >>> browser.getControl(name='field.wikiname').value = wikiname
368- >>> browser.getControl('Save Changes').click()
369- >>> print browser.url
370- http://launchpad.dev/%7Emark/+editwikinames
371- >>> print "\n".join(get_feedback_messages(browser.contents))
372- There is 1 error.
373- The wiki name cannot exceed 100 characters.
374-
375-The invalid value is escaped using HTML entities when displayed back to
376-the user.
377-
378- >>> browser.getControl(name='field.wiki').value = (
379- ... '<script>alert(1);</script>')
380- >>> browser.getControl(name='field.wikiname').value = 'FooBar'
381- >>> browser.getControl('Save Changes').click()
382- >>> print browser.url
383- http://launchpad.dev/%7Emark/+editwikinames
384- >>> print "\n".join(get_feedback_messages(browser.contents))
385- There is 1 error.
386- "&lt;script&gt;alert(1);&lt;/script&gt;" is not a valid URI
387-
388-Only http and https URLs are allowed for wikis.
389-
390- >>> browser.getControl(name='field.wiki').value = "javascript:void"
391- >>> browser.getControl(name='field.wikiname').value = 'FooBar'
392- >>> browser.getControl('Save Changes').click()
393- >>> print browser.url
394- http://launchpad.dev/%7Emark/+editwikinames
395- >>> print "\n".join(get_feedback_messages(browser.contents))
396- There is 1 error.
397- The URI scheme "javascript" is not allowed. Only URIs with the following
398- schemes may be used: http, https
399-
400-Mark can remove any of his wiki names.
401-
402- >>> browser.getControl(name='field.wiki').value = ""
403- >>> browser.getControl(name='field.wikiname').value = ''
404- >>> browser.getControl('Remove', index=0).selected = True
405- >>> browser.getControl('Save Changes').click()
406- >>> print browser.url
407- http://launchpad.dev/~mark
408- >>> print "\n".join(get_feedback_messages(browser.contents))
409- >>> browser.open('http://launchpad.dev/~mark/+editwikinames')
410- >>> print_existing_wikiurls(browser.contents)
411- https://wiki.ubuntu.com/MarkShuttleworth
412
413=== removed file 'lib/lp/registry/templates/person-editwikinames.pt'
414--- lib/lp/registry/templates/person-editwikinames.pt 2010-08-30 22:41:41 +0000
415+++ lib/lp/registry/templates/person-editwikinames.pt 1970-01-01 00:00:00 +0000
416@@ -1,75 +0,0 @@
417-<html
418- xmlns="http://www.w3.org/1999/xhtml"
419- xmlns:tal="http://xml.zope.org/namespaces/tal"
420- xmlns:metal="http://xml.zope.org/namespaces/metal"
421- xmlns:i18n="http://xml.zope.org/namespaces/i18n"
422- metal:use-macro="view/macro:page/main_only"
423- i18n:domain="launchpad"
424->
425-<body>
426-
427-<div metal:fill-slot="main">
428-<div metal:use-macro="context/@@launchpad_form/form">
429-
430- <div metal:fill-slot="widgets">
431- <table id="wikinames">
432-
433- <tal:XXX condition="nothing">
434- # XXX: salgado, 2008-11-25 bug=296739: We should use
435- # context/wiki_names/is_empty here, but we can't do that because
436- # there's a bug preventing us from # updating our version of storm
437- # to trunk.
438- </tal:XXX>
439-
440- <tal:existing_wiki condition="context/wiki_names/any">
441-
442- <tr>
443- <td><label>Existing wiki names</label></td>
444- </tr>
445-
446- <tr>
447- <td><label>Wiki URL</label></td>
448- </tr>
449-
450- <tr tal:repeat="wiki context/wiki_names" class="wikiurl">
451- <td tal:content="wiki/url"></td>
452- <td>
453- <label>
454- <input type="checkbox" value="Remove"
455- tal:attributes="name string:remove_${wiki/id}" />
456- Remove
457- </label>
458- </td>
459- </tr>
460- <tr style="height:2em;"><td></td></tr>
461- </tal:existing_wiki>
462-
463-
464- <tr>
465- <td><label>New wiki name</label></td>
466- </tr>
467-
468- <tal:widget define="widget nocall:view/widgets/wiki">
469- <metal:block use-macro="context/@@launchpad_form/widget_row" />
470- </tal:widget>
471-
472- <tr>
473- <td class="formHelp">Example: https://wiki.ubuntu.com/</td>
474- </tr>
475-
476- <tal:widget define="widget nocall:view/widgets/wikiname">
477- <metal:block use-macro="context/@@launchpad_form/widget_row" />
478- </tal:widget>
479-
480- <tr>
481- <td class="formHelp">Example: YourName.</td>
482- </tr>
483-
484- </table>
485- </div>
486-
487-</div>
488-</div>
489-
490-</body>
491-</html>
492
493=== modified file 'lib/lp/registry/templates/person-portlet-contact-details.pt'
494--- lib/lp/registry/templates/person-portlet-contact-details.pt 2011-05-27 17:28:16 +0000
495+++ lib/lp/registry/templates/person-portlet-contact-details.pt 2011-06-01 12:33:35 +0000
496@@ -114,21 +114,6 @@
497 </div>
498
499 <div class="yui-u two-column-list">
500- <dl tal:condition="view/should_show_wikinames_section">
501- <dt>Wiki:
502- <a tal:replace="structure overview_menu/editwikinames/fmt:icon" />
503- </dt>
504- <dd>
505- <div tal:repeat="wiki context/wiki_names">
506- <a tal:content="wiki/url"
507- tal:attributes="href wiki/url"
508- >WikiName</a>
509- </div>
510- <div tal:condition="context/wiki_names/is_empty">
511- No Wiki names registered.
512- </div>
513- </dd>
514- </dl>
515 <dl tal:condition="view/should_show_ircnicknames_section">
516 <dt>IRC:
517 <a tal:replace="structure overview_menu/editircnicknames/fmt:icon" />
518
519=== modified file 'lib/lp/registry/templates/product-rdf.pt'
520--- lib/lp/registry/templates/product-rdf.pt 2010-10-15 16:28:56 +0000
521+++ lib/lp/registry/templates/product-rdf.pt 2011-06-01 12:33:35 +0000
522@@ -25,8 +25,6 @@
523 1970-01-01 00:00:00
524 </lp:creationDate>
525 <lp:homepage tal:attributes="rdf:resource context/homepageurl" />
526- <lp:wiki tal:condition="context/wikiurl"
527- tal:attributes="rdf:resource context/wikiurl" />
528 <lp:freshmeatProject tal:condition="context/freshmeatproject"
529 tal:content="context/freshmeatproject">
530 freshmeatproject