Beispiel #1
0
def list_user_group_and_permissions(username, siloname=None):
    try:
        u = User.objects.get(username=username)
        if siloname != None:
            group_list = u.groups.filter(name__startswith=siloname)
        else:
            group_list = u.groups.all()
        roles = []
        for g in group_list:
            silo, role = silo_role_from_group(g.name)
            roles.append((silo, role))
        return roles
    except User.DoesNotExist:
        log.error('Error getting user %s. Does the user exist?' % username)
        return False
def list_user_group_and_permissions(username, siloname=None):
    try:
        u = User.objects.get(username=username)
        if siloname != None:
            group_list = u.groups.filter(name__startswith=siloname)
        else:
            group_list = u.groups.all()
        roles = []
        for g in group_list:
            silo, role = silo_role_from_group(g.name)
            roles.append((silo, role))
        return roles
    except User.DoesNotExist:
        log.error('Error getting user %s. Does the user exist?' % username)
        return False
Beispiel #3
0
def list_group_usernames(siloname):
    admins = []
    managers = []
    submitters = []

    for u in User.objects.filter(groups__name__startswith=siloname):
        for group in u.groups.filter(name__startswith=siloname):
            silo, role = silo_role_from_group(group.name)
            username = u.username
            if role == 'administrator' and not username in admins:
                admins.append(username)
            if role == 'manager' and not username in managers:
                managers.append(username)
            if role == 'submitter' and not username in submitters:
                submitters.append(username)
    return (admins, managers, submitters)
def list_group_usernames(siloname):
    admins = []
    managers = []
    submitters = []
    
    for u in User.objects.filter(groups__name__startswith=siloname):
        for group in u.groups.filter(name__startswith=siloname):
            silo, role = silo_role_from_group(group.name)
            username = u.username
            if role == 'administrator' and not username in admins:
                admins.append(username)
            if role == 'manager' and not username in managers:
                managers.append(username)
            if role == 'submitter' and not username in submitters:
                submitters.append(username)
    return (admins, managers, submitters)
def list_group_users(siloname):
    # NOTE: Original code seems to have oddness wrt users with multiple
    # permissions for a single silo.
    # New code mimics this until I can see why
    # would be better if 'permission' key in returned dict was
    # a list of permissions?
    
    group_users =[]
    for u in User.objects.filter(groups__name__startswith=siloname):
        details = {'user_name':u.username,
                   'name':u.profile.name,
                   'firstname':u.first_name,
                   'lastname':u.last_name,
                   'email':u.email}
        for group in u.groups.filter(name__startswith=siloname):
            silo, role = silo_role_from_group(group.name)
            record = {'permission': role}
            record.update(details)
            group_users.append(record)
    
    return group_users
def list_user_details(username, user_object=None):
    try:
        u = user_object
        if u == None:
            u = User.objects.get(username=username)
            log.info("Getting user '%s' information" % username)
        
        user_details = {}
        user_details['user_name'] = u.username
        user_details['name'] = u.profile.name
        user_details['firstname'] = u.first_name
        user_details['lastname'] = u.last_name
        user_details['email'] = u.email
        user_details['groups'] = []
        # groups user belongs to
        for g in u.groups.iterator():
            user_details['groups'].append((silo_role_from_group(g.name)))
        return user_details
        
    except User.DoesNotExist:
        log.error("Error getting user '%s' information. Does the user exist?" % username)
        return {}
Beispiel #7
0
def list_group_users(siloname):
    # NOTE: Original code seems to have oddness wrt users with multiple
    # permissions for a single silo.
    # New code mimics this until I can see why
    # would be better if 'permission' key in returned dict was
    # a list of permissions?

    group_users = []
    for u in User.objects.filter(groups__name__startswith=siloname):
        details = {
            'user_name': u.username,
            'name': u.profile.name,
            'firstname': u.first_name,
            'lastname': u.last_name,
            'email': u.email
        }
        for group in u.groups.filter(name__startswith=siloname):
            silo, role = silo_role_from_group(group.name)
            record = {'permission': role}
            record.update(details)
            group_users.append(record)

    return group_users
Beispiel #8
0
def list_user_details(username, user_object=None):
    try:
        u = user_object
        if u == None:
            u = User.objects.get(username=username)
            log.info("Getting user '%s' information" % username)

        user_details = {}
        user_details['user_name'] = u.username
        user_details['name'] = u.profile.name
        user_details['firstname'] = u.first_name
        user_details['lastname'] = u.last_name
        user_details['email'] = u.email
        user_details['groups'] = []
        # groups user belongs to
        for g in u.groups.iterator():
            user_details['groups'].append((silo_role_from_group(g.name)))
        return user_details

    except User.DoesNotExist:
        log.error("Error getting user '%s' information. Does the user exist?" %
                  username)
        return {}