← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~andrea.corbellini/launchpad/bug-630302 into lp:launchpad

 

Andrea Corbellini has proposed merging lp:~andrea.corbellini/launchpad/bug-630302 into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  #630302 People permalinks
  https://bugs.launchpad.net/bugs/630302


This is my attempt to fix bug #630302. I've set up a new URL: lp.net/people/+id/<person-id> that redirects to the person's homepage (e.g. lp.net/~name). <person-id> is the hexadecimal representation of the ID of the person.

The permalink is shown on the person's homepage, under "User information".
-- 
https://code.launchpad.net/~andrea.corbellini/launchpad/bug-630302/+merge/44061
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~andrea.corbellini/launchpad/bug-630302 into lp:launchpad.
=== modified file 'lib/lp/registry/browser/person.py'
--- lib/lp/registry/browser/person.py	2010-12-17 15:01:53 +0000
+++ lib/lp/registry/browser/person.py	2010-12-17 15:36:18 +0000
@@ -204,6 +204,8 @@
 from canonical.launchpad.webapp.login import logoutPerson
 from canonical.launchpad.webapp.menu import get_current_view
 from canonical.launchpad.webapp.publisher import LaunchpadView
+from canonical.launchpad.webapp.url import urlappend
+from canonical.launchpad.webapp.vhosts import allvhosts
 from canonical.lazr.utils import smartquote
 from canonical.widgets import (
     LaunchpadDropdownWidget,
@@ -306,6 +308,7 @@
     Milestone,
     milestone_sort_key,
     )
+from lp.registry.model.person import Person
 from lp.services.fields import LocationField
 from lp.services.geoip.interfaces import IRequestPreferredLanguages
 from lp.services.openid.adapters.openid import CurrentOpenIDEndPoint
@@ -778,6 +781,18 @@
         return self.redirectSubTree(
             canonical_url(person, request=self.request))
 
+    @stepthrough('+id')
+    def redirect_id(self, person_id_hex):
+        """Redirect to the canonical_url of the person with the given ID."""
+        try:
+            person_id = int(person_id_hex, 16)
+        except ValueError:
+            raise NotFoundError
+        person = Person.selectOne(Person.q.id == person_id)
+        if person:
+            return self.redirectSubTree(canonical_url(person))
+        raise NotFoundError
+
     @stepto('+me')
     def me(self):
         me = getUtility(ILaunchBag).user
@@ -2863,6 +2878,13 @@
             return formatter(content).text_to_html()
 
     @cachedproperty
+    def permalink(self):
+        """Return the permalink that points to this account."""
+        rooturl = allvhosts.configs['mainsite'].rooturl
+        link = 'people/+id/%x' % self.context.id
+        return urlappend(rooturl, link)
+
+    @cachedproperty
     def recently_approved_members(self):
         members = self.context.getMembersByStatus(
             TeamMembershipStatus.APPROVED,

=== modified file 'lib/lp/registry/stories/person/xx-person-home.txt'
--- lib/lp/registry/stories/person/xx-person-home.txt	2010-08-27 22:40:36 +0000
+++ lib/lp/registry/stories/person/xx-person-home.txt	2010-12-17 15:36:18 +0000
@@ -138,6 +138,18 @@
     English
 
 
+Permalink
+---------
+
+Each person has a permalink, which is shown on the homepage and is
+visible by everybody:
+
+    >>> browser.open('http://launchpad.dev/~name16')
+    >>> print extract_text(find_tag_by_id(browser.contents, 'permalink'))
+    Permalink:
+    http://launchpad.dev/people/+id/10
+
+
 Summary Pagelets
 ----------------
 

=== modified file 'lib/lp/registry/templates/person-portlet-contact-details.pt'
--- lib/lp/registry/templates/person-portlet-contact-details.pt	2010-12-01 22:05:51 +0000
+++ lib/lp/registry/templates/person-portlet-contact-details.pt	2010-12-17 15:36:18 +0000
@@ -200,6 +200,11 @@
              tal:content="context/karma">342</a>
       </dd>
     </dl>
+
+    <dl id="permalink">
+      <dt>Permalink:</dt>
+      <dd tal:content="view/permalink">None</dd>
+    </dl>
   </div>
 
 </div>