Beispiel #1
0
def add_local_auth_user_to_group(name, group_name):
    user_group = LocalAuthUserGroup.objects(user_group_name=group_name).first()
    if user_group:
        user = get_local_auth_user(name)
        secondary_group = user['secondaryGroup'] + [group_name]
        update_local_auth_user_secondary_group(name, secondary_group)
    else:
        raise DatabaseError('No such local auth user group!')
Beispiel #2
0
def remove_local_auth_user_from_group(name, group_name):
    user_group = LocalAuthUserGroup.objects(user_group_name=group_name).first()
    if user_group:
        user = get_local_auth_user(name)
        secondary_group = filter(lambda group: group != group_name,
                                 user['secondaryGroup'])
        update_local_auth_user_secondary_group(name, secondary_group)
    else:
        raise DatabaseError('No such local auth user group!')
Beispiel #3
0
def get_local_auth_user_group(name):
    user_group = LocalAuthUserGroup.objects(user_group_name=name).first()
    if user_group:
        return {
            'name': user_group.user_group_name,
            'description': user_group.user_group_desc
        }
    else:
        raise DatabaseError('No such local auth user group!')
Beispiel #4
0
def get_local_auth_user_from_group(group_name):
    user_group = LocalAuthUserGroup.objects(user_group_name=group_name).first()
    if user_group:
        users = list_local_auth_user()
        user_in_primary_group = filter(
            lambda user: user['primaryGroup'] == group_name, users)
        user_in_secondary_group = filter(
            lambda user: group_name in user['secondaryGroup'], users)
        return user_in_primary_group + user_in_secondary_group
    else:
        raise DatabaseError('No such local auth user group!')
Beispiel #5
0
def delete_local_auth_user_group(name):
    user_group = LocalAuthUserGroup.objects(user_group_name=name).first()
    if user_group:
        user_group.delete()
    else:
        raise DatabaseError('No such local auth user group!')
Beispiel #6
0
def update_local_auth_user_group(name, desc):
    user_group = LocalAuthUserGroup.objects(user_group_name=name).first()
    if user_group:
        user_group.update(set__user_group_desc=desc)
    else:
        raise DatabaseError('No such local auth user group!')
Beispiel #7
0
def create_local_auth_user_group(name, desc):
    user_group = LocalAuthUserGroup.objects(user_group_name=name).first()
    if user_group:
        raise DatabaseError('Local auth user group already exists!')
    else:
        LocalAuthUserGroup(user_group_name=name, user_group_desc=desc).save()