~doctormo/erato/trunk

« back to all changes in this revision

Viewing changes to art_website/common/launchpad.py

  • Committer: Martin Owens
  • Date: 2010-10-20 20:33:00 UTC
  • Revision ID: doctormo@gmail.com-20101020203300-9vsolpbwc2tbcxoc
Manual merge in changes from designhub branch for common directory.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# -*- coding: utf-8 -*-
2
2
#
3
 
# Copyright 2010, Martin Owens and Adnane Belmadiaf.
 
3
# Copyright 2010, LoCo Directory Project,
 
4
#                 Adnane Belmadiaf
4
5
#
5
6
# This program is free software: you can redistribute it and/or modify
6
7
# it under the terms of the GNU Affero General Public License as
20
21
from launchpadlib.errors import HTTPError
21
22
from launchpadlib.launchpad import EDGE_SERVICE_ROOT
22
23
 
23
 
from teams.models import *
24
24
from django.conf import settings
25
25
 
26
26
import os
64
64
    user_in_groups = user.groups.filter(name__exact=team.lp_name)
65
65
    return (user_in_groups.count() >= 1)
66
66
 
67
 
def is_admin_or_owner(username, team):
68
 
    # check just using the LD data
69
 
    if username == team.owner_profile.user.username:
70
 
        return True
71
 
    if team.admin_profiles.filter(user__username=username):
72
 
        return True
73
 
    if is_debug_user(username):
74
 
        return True
75
 
    # more complicated check :-/
76
 
    lp = lp_login()
77
 
    if not lp:
78
 
        return False
79
 
    try:
80
 
        lp_team = lp.people[team.lp_name]
81
 
    except:
82
 
        print >> sys.stderr, 'Something went wrong.'
83
 
        return False
84
 
    if lp_team.team_owner.is_team:
85
 
        if filter(lambda a: a.name == username, lp_team.team_owner.members):
86
 
            return True
87
 
    return False
88
 
 
89
67
def get_mugshot_url(lp, identity):
90
68
    # Not ideal, but until LP #336943
91
69
    # or similar, we are in a hard spot.