Merge lp:~daker/loco-team-portal/fix.611294 into lp:loco-team-portal

Proposed by Adnane Belmadiaf
Status: Merged
Approved by: Adnane Belmadiaf
Approved revision: 606
Merged at revision: 617
Proposed branch: lp:~daker/loco-team-portal/fix.611294
Merge into: lp:loco-team-portal
Diff against target: 101 lines (+11/-6)
2 files modified
loco_directory/common/launchpad.py (+10/-5)
loco_directory/settings.py (+1/-1)
To merge this branch: bzr merge lp:~daker/loco-team-portal/fix.611294
Reviewer Review Type Date Requested Status
LoCo Team Portal Developers Pending
Review via email: mp+146288@code.launchpad.net

Commit message

Switched to login.ubuntu.com

To post a comment you must log in.
606. By Adnane Belmadiaf

Fixed get_permanent_openid_from_username

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'loco_directory/common/launchpad.py'
2--- loco_directory/common/launchpad.py 2012-11-26 21:07:29 +0000
3+++ loco_directory/common/launchpad.py 2013-02-04 22:43:21 +0000
4@@ -1,12 +1,11 @@
5 # -*- coding: utf-8 -*-
6 from launchpadlib.launchpad import Launchpad
7-from launchpadlib.errors import HTTPError
8 from django.conf import settings
9
10 import os
11-import sys
12 import urllib2
13
14+
15 def is_debug_user(username):
16 try:
17 if settings.DEBUG and username in settings.DEBUG_USERS:
18@@ -15,6 +14,7 @@
19 return False
20 return False
21
22+
23 def lp_login(lp_instance='production'):
24 cachedir = os.path.join(settings.PROJECT_PATH, 'lp_data/cache')
25 client_ident = getattr(settings, 'LP_PROJECT_NAME', "LoCo Team Portal")
26@@ -29,6 +29,7 @@
27 return None
28 return launchpad
29
30+
31 def is_user_on_loco_council(user):
32 if not user.is_authenticated():
33 return False
34@@ -39,6 +40,7 @@
35 lc_in_groups = user.groups.filter(name__exact='ubuntu-lococouncil')
36 return (lc_in_groups.count() == 1)
37
38+
39 def is_team_member(user, team):
40 if not user.is_authenticated():
41 return False
42@@ -47,6 +49,7 @@
43 user_in_groups = user.groups.filter(name__exact=team.lp_name)
44 return (user_in_groups.count() >= 1)
45
46+
47 def is_admin_or_owner(username, team):
48 # check just using the LD data
49 if username == team.owner_profile.user.username:
50@@ -57,6 +60,7 @@
51 return True
52 return False
53
54+
55 def get_mugshot_url(url):
56 # Not ideal, but until LP #713873
57 # or similar, we are in a hard spot.
58@@ -69,6 +73,7 @@
59 # 404 or some other issue that means we should default to False
60 return "https://launchpad.net/@@/person-logo"
61
62+
63 def get_user_timezone(username, lp=None):
64 timezone = 'UTC'
65 if username is None:
66@@ -93,11 +98,11 @@
67 html = f.read()
68 services = OpenIDServiceEndpoint().fromHTML(url, html)
69 if services is not None and len(services) > 0:
70+ services[0].local_id = services[0].local_id.replace('launchpad.net', 'ubuntu.com')
71 return services[0]
72 else:
73 return None
74- # ... or use this line if you want the Ubuntu SSO OpenID:
75- # return services[0].local_id.replace('launchpad.net', 'ubuntu.com')
76+
77
78 def set_user_openid(user, force=False):
79 from django_openid_auth.models import UserOpenID
80@@ -105,7 +110,7 @@
81 if len(openids) == 0 or force:
82 if len(openids) == 0:
83 openid_assoc = UserOpenID(user=user)
84- else :
85+ else:
86 openid_assoc = openids[0]
87 openid = get_permanent_openid_from_username(user.username)
88 if openid is not None:
89
90=== modified file 'loco_directory/settings.py'
91--- loco_directory/settings.py 2012-12-26 21:27:08 +0000
92+++ loco_directory/settings.py 2013-02-04 22:43:21 +0000
93@@ -186,7 +186,7 @@
94
95 # If set, always use this as the identity URL rather than asking the
96 # user. This only makes sense if it is a server URL.
97-OPENID_SSO_SERVER_URL = 'https://login.launchpad.net/'
98+OPENID_SSO_SERVER_URL = 'https://login.ubuntu.com/'
99
100 # Automatically map lp team membership to ld group membership
101 OPENID_LAUNCHPAD_TEAMS_MAPPING_AUTO = True

Subscribers

People subscribed via source and target branches