parameters: (**kwargs)
return_statement: return user
docstring: add a user in database
      数据库中添加用户
docstring_summary: add a user in database
      数据库中添加用户
docstring_tokens: add a user in database 数据库中添加用户
function: def db_add_user(**kwargs):
      """
      add a user in database
      数据库中添加用户
      """
      groups_post = kwargs.pop('groups')
      admin_groups = kwargs.pop('admin_groups')
      role = kwargs.get('role', 'CU')
      user = User(**kwargs)
      user.set_password(kwargs.get('password'))
      user.save()
      if groups_post:
          group_select = []
          for group_id in groups_post:
              group = UserGroup.objects.filter(id=group_id)
              group_select.extend(group)
          user.group = group_select
  
      if admin_groups and role == 'GA':  # 如果是组管理员就要添加组管理员和组到管理组中
          for group_id in admin_groups:
              group = get_object(UserGroup, id=group_id)
              if group:
                  AdminGroup(user=user, group=group).save()
      return user
function_tokens: def db_add_user ( * * kwargs ) : groups_post = kwargs . pop ( 'groups' ) admin_groups = kwargs . pop ( 'admin_groups' ) role = kwargs . get ( 'role' , 'CU' ) user = User ( * * kwargs ) user . set_password ( kwargs . get ( 'password' ) ) user . save ( ) if groups_post : group_select = [ ] for group_id in groups_post : group = UserGroup . objects . filter ( id = group_id ) group_select . extend ( group ) user . group = group_select if admin_groups and role == 'GA' : # 如果是组管理员就要添加组管理员和组到管理组中 for group_id in admin_groups : group = get_object ( UserGroup , id = group_id ) if group : AdminGroup ( user = user , group = group ) . save ( ) return user