当前位置: 首页>>代码示例>>Python>>正文


Python Utility.get_nested方法代码示例

本文整理汇总了Python中utility.utility.Utility.get_nested方法的典型用法代码示例。如果您正苦于以下问题:Python Utility.get_nested方法的具体用法?Python Utility.get_nested怎么用?Python Utility.get_nested使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在utility.utility.Utility的用法示例。


在下文中一共展示了Utility.get_nested方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: nest_row

# 需要导入模块: from utility.utility import Utility [as 别名]
# 或者: from utility.utility.Utility import get_nested [as 别名]
def nest_row(row, id=None):
    if id is not None:
        row['_id'] = id
    appointment = Utility.get_nested(Appointments, AppointmentSerializer, row['appointment'])

    if len(appointment) > 0:
        appointment['host'] = Utility.get_nested(UserProfile, UserSerializer, appointment['host'])
        appointment['visitor'] = Utility.get_nested(Visitors, VisitorSerializer, appointment['visitor'])
        del appointment['visitor']['image']
        del appointment['host']['image']
        appointment['log'] = row
        row = appointment
    return row
开发者ID:cogfix,项目名称:vilogged-api,代码行数:15,代码来源:views.py

示例2: post

# 需要导入模块: from utility.utility import Utility [as 别名]
# 或者: from utility.utility.Utility import get_nested [as 别名]
    def post(self, request):

        config = ConfigManager().get_config()
        user = None

        username = request.data.get('username', None)
        password = request.data.get('password', None)

        if config.get('authType', 'api') == 'api':
            user = authenticate(username=username, password=password)

        if config.get('authType', 'api') == 'ldap':
            user = LDAPManager().ldap_login(username, password)

        if user is not None:
            if user.is_active:
                token = Token.objects.get(user=user)
                serializer = UserSerializer(user)
                data = serializer.data
                del data['password']
                data['department'] = Utility.get_nested(Department, DepartmentSerializer, data['department'])

                return Response({'user': data, 'token': token.key})
            else:
                return Response({'detail': 'User not active'}, status=status.HTTP_400_BAD_REQUEST)

        return Response({'detail': 'invalid credentials provided'}, status=status.HTTP_401_UNAUTHORIZED)
开发者ID:musakunte,项目名称:vilogged-api,代码行数:29,代码来源:views.py

示例3: nest_row

# 需要导入模块: from utility.utility import Utility [as 别名]
# 或者: from utility.utility.Utility import get_nested [as 别名]
def nest_row(row, id=None):
    if id is not None:
        row['_id'] = id
    row['visitor'] = Utility.get_nested(Visitors, VisitorSerializer, row['visitor'])
    row['host'] = Utility.get_nested(UserProfile, UserSerializer, row['host'])
    row['entrance'] = Utility.get_nested(Entrance, EntranceSerializer, row['entrance'])
    if type(row['visitor']) is dict and len(row['visitor']) > 0:
        row['visitor']['company'] = Utility.get_nested(Company, CompanySerializer, row['visitor']['company'])
        row['visitor']['group'] = Utility.get_nested(VisitorGroup, VisitorGroupSerializer, row['visitor']['group'])

    if type(row['host']) is dict and len(row['host']) > 0:
        row['host']['department'] = Utility.get_nested(Department, DepartmentSerializer, row['host']['department'])

    return row
开发者ID:musakunte,项目名称:vilogged-api,代码行数:16,代码来源:views.py


注:本文中的utility.utility.Utility.get_nested方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。