Adnane Belmadiaf has proposed merging lp:~daker/loco-directory/fix.734520 into 
lp:loco-directory.

Requested reviews:
  loco-directory-dev (loco-directory-dev)
Related bugs:
  Bug #734520 in LoCo Team Directory: "profile images not displaying correctly 
if no image on LP"
  https://bugs.launchpad.net/loco-directory/+bug/734520

For more details, see:
https://code.launchpad.net/~daker/loco-directory/fix.734520/+merge/68998
-- 
https://code.launchpad.net/~daker/loco-directory/fix.734520/+merge/68998
Your team loco-directory-dev is requested to review the proposed merge of 
lp:~daker/loco-directory/fix.734520 into lp:loco-directory.
=== modified file 'loco_directory/common/launchpad.py'
--- loco_directory/common/launchpad.py	2011-03-04 18:16:03 +0000
+++ loco_directory/common/launchpad.py	2011-07-24 16:33:45 +0000
@@ -8,6 +8,7 @@
 
 import os
 import sys
+import urllib2
 
 def is_debug_user(username):
     try:
@@ -58,16 +59,17 @@
     if is_debug_user(username):
         return True
 
-def get_mugshot_url(lp, identity):
-    # Not ideal, but until LP #336943
+def get_mugshot_url(url):
+    # Not ideal, but until LP #713873
     # or similar, we are in a hard spot.
     # When this bug is fixed, this can be made cleaner.
     try:
-       lp.people[identity].mugshot.open()
-       return lp.people[identity].mugshot_link or "https://api.launchpad.net/1.0/~%s/mugshot"; % (identity)
-    except HTTPError:
-       # 404 or some other issue that means we should default to False
-       return "https://api.launchpad.net/1.0/ubuntu/mugshot";
+        con = urllib2.urlopen(url)
+        con.close()
+        return url
+    except urllib2.HTTPError, e:
+        # 404 or some other issue that means we should default to False
+        return "https://launchpad.net/@@/person-logo";
 
 def get_user_timezone(username, lp=None):
     timezone = 'UTC'

=== modified file 'loco_directory/templates/events/team_event_detail_attendees.inc.html'
--- loco_directory/templates/events/team_event_detail_attendees.inc.html	2011-07-23 23:00:50 +0000
+++ loco_directory/templates/events/team_event_detail_attendees.inc.html	2011-07-24 16:33:45 +0000
@@ -40,7 +40,6 @@
     <tbody>
         {% for registration in team_event_object.attendee_set.all %}
         <tr class="team_event_list_row {% cycle "odd" "even" %}">
-<!--- Commenting out until bug #734520 is fixed.
             <td align="center" class="attendee-mugshot">
                 <a href="https://launchpad.net/~{{registration.attendee_profile.user.username}}"; >
                 {% if registration.attendee_profile.mugshot %}
@@ -48,7 +47,6 @@
                 {% endif %}
                 </a>
             </td>
--->
             <td align="center" class="attendee-cell">
                 <a href="https://launchpad.net/~{{registration.attendee_profile.user.username}}"; >{{registration.attendee_profile.realname}}</a>
             </td>

=== modified file 'loco_directory/userprofiles/management/commands/update-profiles.py'
--- loco_directory/userprofiles/management/commands/update-profiles.py	2010-12-28 21:41:10 +0000
+++ loco_directory/userprofiles/management/commands/update-profiles.py	2011-07-24 16:33:45 +0000
@@ -25,13 +25,11 @@
             if not ld_user.username in USER_BLACKLIST:
                 profile, created = UserProfile.objects.get_or_create(user=ld_user)
                 try:
+                    print "updating %s" % ld_user
                     lp_user = lp.people[ld_user.username]
                     profile.tz = lp_user.time_zone or "UTC"
                     profile.realname = lp_user.display_name or user.username
-                    if lp_user.logo_link.startswith("https://";) :
-                       profile.mugshot = lp_user.logo_link
-                    else:
-                       profile.mugshot = "https://launchpad.net/@@/person-logo";
+                    profile.mugshot = launchpad.get_mugshot_url(lp_user.logo_link)
                     profile.save()
                 except Exception, e:
                     print "Error updating %s" % ld_user

_______________________________________________
Mailing list: https://launchpad.net/~loco-directory-dev
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~loco-directory-dev
More help   : https://help.launchpad.net/ListHelp

Reply via email to