Merge lp:~cjohnston/loco-team-portal/bugfix-lp-610040 into lp:loco-team-portal

Proposed by Chris Johnston
Status: Merged
Approved by: Michael Hall
Approved revision: 209
Merged at revision: 211
Proposed branch: lp:~cjohnston/loco-team-portal/bugfix-lp-610040
Merge into: lp:loco-team-portal
Diff against target: 70 lines (+18/-4)
3 files modified
loco_directory/common/launchpad.py (+16/-3)
loco_directory/events/views.py (+1/-1)
loco_directory/local_settings.py.sample (+1/-0)
To merge this branch: bzr merge lp:~cjohnston/loco-team-portal/bugfix-lp-610040
Reviewer Review Type Date Requested Status
Michael Hall (community) Approve
Daniel Holbach (community) Needs Fixing
Review via email: mp+31346@code.launchpad.net

Description of the change

Adds DEBUG_USER to allow for local testing.

To post a comment you must log in.
207. By Chris Johnston

Fixes intentions and adds DEBUG to is_admin_or_owner

208. By Chris Johnston

Removes user.is_authenticated() from is_admin_or_owner

Revision history for this message
Daniel Holbach (dholbach) wrote :

 - is_admin_or_owner needs the user.is_authenticated() check too
 - "request.user.is_authenticated()" check in global_event_detail in events/views.py can be removed
 - I don't think we need DEBUG_USER in settings.py
 - can we make it DEBUG_USERS instead? so it'd be possible to specify more than one person?

Apart from that: good work.

review: Needs Fixing
Revision history for this message
Michael Hall (mhall119) wrote :

is_admin_or_owner doesn't pass a user object, just a username, so we can't call is_authenticated().

I told him to put it in settings.py because I didn't want Python failing if the user wasn't using a local_settings.py

I'm not sure there's much of a case for having multiple debugging users at the same time, can you elaborate on how that would be useful?

209. By Chris Johnston

Adds is_debug_user

Revision history for this message
Michael Hall (mhall119) wrote :

Works well for me.

review: Approve

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 2010-06-18 18:46:02 +0000
3+++ loco_directory/common/launchpad.py 2010-07-30 16:16:42 +0000
4@@ -10,6 +10,14 @@
5 import os
6 import sys
7
8+def is_debug_user(username):
9+ try:
10+ if settings.DEBUG and username in settings.DEBUG_USERS:
11+ return True
12+ except AttributeError:
13+ return False
14+ return False
15+
16 def lp_login(lp_instance=EDGE_SERVICE_ROOT):
17 cachedir = os.path.join(settings.PROJECT_PATH, 'lp_data/cache')
18 client_ident = getattr(settings, 'LP_PROJECT_NAME', "LoCo Directory")
19@@ -22,13 +30,17 @@
20
21 def is_user_on_loco_council(user):
22 if not user.is_authenticated():
23- return False
24+ return False
25+ if is_debug_user(user.username):
26+ return True
27 lc_in_groups = user.groups.filter(name__exact='ubuntu-lococouncil')
28 return (lc_in_groups.count() == 1)
29
30 def is_team_member(user, team):
31 if not user.is_authenticated():
32- return False
33+ return False
34+ if is_debug_user(user.username):
35+ return True
36 user_in_groups = user.groups.filter(name__exact=team.lp_name)
37 return (user_in_groups.count() >= 1)
38
39@@ -38,7 +50,8 @@
40 return True
41 if team.admins.filter(lpid=username):
42 return True
43-
44+ if is_debug_user(username):
45+ return True
46 # more complicated check :-/
47 lp = lp_login()
48 try:
49
50=== modified file 'loco_directory/events/views.py'
51--- loco_directory/events/views.py 2010-07-29 07:54:21 +0000
52+++ loco_directory/events/views.py 2010-07-30 16:16:42 +0000
53@@ -355,7 +355,7 @@
54 global_event_object = get_object_or_404(GlobalEvent, pk=global_event_id)
55 add_team_event = (request.user and request.user.is_authenticated() and \
56 request.user.groups.exclude(name__exact='ubuntu-lococouncil'))
57- is_on_lc = request.user.is_authenticated() and launchpad.is_user_on_loco_council(request.user)
58+ is_on_lc = launchpad.is_user_on_loco_council(request.user)
59 context = {
60 'global_event_object': global_event_object,
61 'add_team_event': add_team_event,
62
63=== modified file 'loco_directory/local_settings.py.sample'
64--- loco_directory/local_settings.py.sample 2010-02-16 17:14:13 +0000
65+++ loco_directory/local_settings.py.sample 2010-07-30 16:16:42 +0000
66@@ -5,3 +5,4 @@
67
68 SECRET_KEY = ''
69
70+DEBUG_USERS = ('')

Subscribers

People subscribed via source and target branches