repair_team_members.py (AEN 4.1.3) — Anaconda Enterprise 4.4 documentation

Anaconda Enterprise: Documentation

# repair_team_members.py (AEN 4.1.3)

    from wk_server.base import init as wk_server_init
    from wk_server.tasks import add_team_member
    import wk_server.database as db

    wk_server_init()

    users = db.get_users()
    for user in users:
        projects = db.get_projects(user, user)
        for p in projects:
            if not p.get('team'):
                continue
            print user['username'], p['name'], p['team']
            for team in p['team']:
                team_member = db.get_user(_id=team)
                print 'adding', user['username'], p['name'], p['team'], team_member['username']
                add_team_member(user['_id'], user['_id'], p['name'], team_member['_id'])