def _create_new_user_account(connection, emp_username, emp_fullname, add_to_user_groups): # when user is created it is automatically added to user group "Everyone" # and is granted rights to Browse and Read this user group new_usr = User.create(connection=connection, username=emp_username, full_name=emp_fullname, trust_id=emp_username) # add user to user groups with provided names (during creation it is added to "Everyone" # noqa for user_group_name in add_to_user_groups: user_group_ = get_user_group(connection=connection, name=user_group_name) if user_group_: user_group_.add_users(users=new_usr)
}, { 'username': '******', 'fullName': 'Mark Jones' }, { 'username': '******', 'fullName': 'Steve Brown' }, { 'username': '******', 'fullName': 'James Davis' }, { 'username': '******', 'fullName': 'Thomas Wilson' }] for u in users_array: User.create(connection=conn, username=u['username'], full_name=u['fullName']) # create a single user and get users which name begins with "John" and have # additional filter for initials User.create(connection=conn, username="******", full_name="John Smith") my_users = list_users(connection=conn, name_begins="John", initials="JS") # get all user groups (you can also add additional filters as for users) and # create a new one user_groups_list = list_user_groups(connection=conn) UserGroup.create(connection=conn, name="Special Users") # get user, user group and add this user to this user group user_ = User(connection=conn, name="John Smith") user_group_ = UserGroup(connection=conn, name="Special Users")