Ronnie has proposed merging
lp:~ronnie.vd.c/loco-directory/714718_team_owner_team into lp:loco-directory.
Requested reviews:
loco-directory-dev (loco-directory-dev)
Related bugs:
#714718 lpupdate.py should check if the team_owner is a person (not a team)
https://bugs.launchpad.net/bugs/714718
For more details, see:
https://code.launchpad.net/~ronnie.vd.c/loco-directory/714718_team_owner_team/+merge/49121
team owner and team_admins which are teams itself now uses users of the subteam
--
https://code.launchpad.net/~ronnie.vd.c/loco-directory/714718_team_owner_team/+merge/49121
Your team loco-directory-dev is requested to review the proposed merge of
lp:~ronnie.vd.c/loco-directory/714718_team_owner_team into lp:loco-directory.
=== modified file 'loco_directory/common/launchpad.py'
--- loco_directory/common/launchpad.py 2010-12-21 03:11:18 +0000
+++ loco_directory/common/launchpad.py 2011-02-09 19:40:51 +0000
@@ -56,19 +56,6 @@
return True
if is_debug_user(username):
return True
- # more complicated check :-/
- lp = lp_login()
- if not lp:
- return False
- try:
- lp_team = lp.people[team.lp_name]
- except:
- print >> sys.stderr, 'Something went wrong.'
- return False
- if lp_team.team_owner.is_team:
- if filter(lambda a: a.name == username, lp_team.team_owner.members):
- return True
- return False
def get_mugshot_url(lp, identity):
# Not ideal, but until LP #336943
=== modified file 'loco_directory/teams/management/commands/lpupdate.py'
--- loco_directory/teams/management/commands/lpupdate.py 2010-12-21 02:34:13 +0000
+++ loco_directory/teams/management/commands/lpupdate.py 2011-02-09 19:40:51 +0000
@@ -17,10 +17,14 @@
return admin_dict
def update_admins(ld_team, lp_team, lp):
+ admins = set(get_team_admins(lp_team))
+ team_owner = lp_team.team_owner
+ if team_owner.is_team:
+ admins.union(set(team_owner.participants))
ld_admin_names = create_admin_dict([(a.user.username, a.realname) \
for a in ld_team.admin_profiles.all()])
lp_admin_names = create_admin_dict([(a.name, a.display_name) \
- for a in lp_team.getMembersByStatus(status='Administrator')])
+ for a in admins])
ld_admin_set = set(ld_admin_names.keys())
lp_admin_set = set(lp_admin_names.keys())
for admin_name in ld_admin_set.difference(lp_admin_set):
@@ -35,6 +39,22 @@
admin.tz = launchpad.get_user_timezone(admin_name, lp)
admin.save()
ld_team.admin_profiles.add(admin)
+
+def get_team_owner(lp_team):
+ owner = lp_team.team_owner
+ if owner.is_team:
+ return get_team_owner(owner)
+ return owner
+
+def get_team_admins(lp_team):
+ ''' Get all the admins of a team (recursive) '''
+ admins = []
+ for admin in lp_team.getMembersByStatus(status='Administrator'):
+ if admin.is_team:
+ admins.extend(admin.participants)
+ else:
+ admins.append(admin)
+ return admins
class Command(NoArgsCommand):
@@ -53,12 +73,12 @@
for l in locos:
if not existing_locos or l.name not in [b.lp_name for b in existing_locos]:
team = models.Team(lp_name=l.name, name=l.display_name,
- owner_profile=create_profile(l.team_owner.name))
+ owner_profile=create_profile(get_team_owner(l).name))
team.save()
else:
team = filter(lambda a: a.lp_name == l.name, existing_locos)[0]
team.name = l.display_name
- team.owner_profile = create_profile(l.team_owner.name)
+ team.owner_profile = create_profile(get_team_owner(l).name)
update_admins(team, l, lp)
if not existing_groups or l.name not in [g.name for g in existing_groups]:
_______________________________________________
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