本文整理匯總了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