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
=== modified file 'loco_directory/common/launchpad.py'
--- loco_directory/common/launchpad.py 2010-06-18 18:46:02 +0000
+++ loco_directory/common/launchpad.py 2010-07-30 16:16:42 +0000
@@ -10,6 +10,14 @@
10import os10import os
11import sys11import sys
1212
13def is_debug_user(username):
14 try:
15 if settings.DEBUG and username in settings.DEBUG_USERS:
16 return True
17 except AttributeError:
18 return False
19 return False
20
13def lp_login(lp_instance=EDGE_SERVICE_ROOT):21def lp_login(lp_instance=EDGE_SERVICE_ROOT):
14 cachedir = os.path.join(settings.PROJECT_PATH, 'lp_data/cache')22 cachedir = os.path.join(settings.PROJECT_PATH, 'lp_data/cache')
15 client_ident = getattr(settings, 'LP_PROJECT_NAME', "LoCo Directory")23 client_ident = getattr(settings, 'LP_PROJECT_NAME', "LoCo Directory")
@@ -22,13 +30,17 @@
2230
23def is_user_on_loco_council(user):31def is_user_on_loco_council(user):
24 if not user.is_authenticated():32 if not user.is_authenticated():
25 return False33 return False
34 if is_debug_user(user.username):
35 return True
26 lc_in_groups = user.groups.filter(name__exact='ubuntu-lococouncil')36 lc_in_groups = user.groups.filter(name__exact='ubuntu-lococouncil')
27 return (lc_in_groups.count() == 1)37 return (lc_in_groups.count() == 1)
2838
29def is_team_member(user, team):39def is_team_member(user, team):
30 if not user.is_authenticated():40 if not user.is_authenticated():
31 return False41 return False
42 if is_debug_user(user.username):
43 return True
32 user_in_groups = user.groups.filter(name__exact=team.lp_name)44 user_in_groups = user.groups.filter(name__exact=team.lp_name)
33 return (user_in_groups.count() >= 1)45 return (user_in_groups.count() >= 1)
3446
@@ -38,7 +50,8 @@
38 return True50 return True
39 if team.admins.filter(lpid=username):51 if team.admins.filter(lpid=username):
40 return True52 return True
41 53 if is_debug_user(username):
54 return True
42 # more complicated check :-/55 # more complicated check :-/
43 lp = lp_login()56 lp = lp_login()
44 try:57 try:
4558
=== modified file 'loco_directory/events/views.py'
--- loco_directory/events/views.py 2010-07-29 07:54:21 +0000
+++ loco_directory/events/views.py 2010-07-30 16:16:42 +0000
@@ -355,7 +355,7 @@
355 global_event_object = get_object_or_404(GlobalEvent, pk=global_event_id)355 global_event_object = get_object_or_404(GlobalEvent, pk=global_event_id)
356 add_team_event = (request.user and request.user.is_authenticated() and \356 add_team_event = (request.user and request.user.is_authenticated() and \
357 request.user.groups.exclude(name__exact='ubuntu-lococouncil'))357 request.user.groups.exclude(name__exact='ubuntu-lococouncil'))
358 is_on_lc = request.user.is_authenticated() and launchpad.is_user_on_loco_council(request.user)358 is_on_lc = launchpad.is_user_on_loco_council(request.user)
359 context = {359 context = {
360 'global_event_object': global_event_object,360 'global_event_object': global_event_object,
361 'add_team_event': add_team_event,361 'add_team_event': add_team_event,
362362
=== modified file 'loco_directory/local_settings.py.sample'
--- loco_directory/local_settings.py.sample 2010-02-16 17:14:13 +0000
+++ loco_directory/local_settings.py.sample 2010-07-30 16:16:42 +0000
@@ -5,3 +5,4 @@
55
6SECRET_KEY = '' 6SECRET_KEY = ''
77
8DEBUG_USERS = ('')

Subscribers

People subscribed via source and target branches