當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。