예제 #1
0
파일: database.py 프로젝트: sherry1123/xs
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!')
예제 #2
0
파일: database.py 프로젝트: sherry1123/xs
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!')
예제 #3
0
파일: database.py 프로젝트: sherry1123/xs
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!')
예제 #4
0
파일: database.py 프로젝트: sherry1123/xs
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!')
예제 #5
0
파일: database.py 프로젝트: sherry1123/xs
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!')
예제 #6
0
파일: database.py 프로젝트: sherry1123/xs
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!')
예제 #7
0
파일: database.py 프로젝트: sherry1123/xs
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()