本文整理汇总了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
示例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)
示例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