All pastes #823864 Raw Edit

Anonymous

public text v1 · immutable
·published 2007-12-19 17:13 UTC
rendered paste body
def canApplyGroup(userName, groupName, applyUserName, g=None):
    if not g:
        g = Groups.byUserName(userName)
    # User must satisfy all dependencies to join.
    # This is bypassed for people already in the group and for the
    # owner of the group (when they initially make it).
    group = Groups.groups(groupName)[groupName]
    requirements = group.fedoraGroupRequires.split()
    for req in requirements:
        try:
            g[req].cn
        except KeyError:
            return
    # A user can apply themselves, and FAS admins can apply other people.
    if (userName == applyUserName) or \
        isAdmin(userName, g):
        return True
    else:
        return False