def condition_parse(data): if data['conjunction'] is not None: values = Q(_connector=data['conjunction'].upper()) for v in data['filters']: values.children.append(condition_parse(v)) return values else: return QF().parseField(data['field'], data['operator'], data['values'][0])
def post(self, request, *args, **kwargs): # 反向生成URL request.versioning_scheme.reverse('statamazonskuuvday', request=request) qf = QF() try: result = qf.parseRequestToFilter(request, StatAmazonSkuUvDayDv, StatAmazonSkuUvDayDvVo) return Response(result) except APIException as e: print(e) return Response(qf.unsuccessful())
def post(self, request, *args, **kwargs): request.versioning_scheme.reverse('statamazonsku', request=request) qf = QF() try: result = qf.parseRequestToFilter(request, ProductAsinModel, StatAmazonSkuVo) return Response(result) except APIException as e: print(e) return Response(qf.unsuccessful())
def post(self, request, *args, **kwargs): request.versioning_scheme.reverse('statamazonkeywordlistset', request=request) qf = QF() try: result = qf.parseRequestToFilter(request, SkuKeywordModel, StatAmazonKeywordVo) return Response(result) except APIException as e: print(e) return Response(qf.unsuccessful())
def post(self, request, *args, **kwargs): request.versioning_scheme.reverse('statauthdepartment', request=request) qf = QF() try: result = qf.parseRequestToFilter(request, DepartmentModel, StatAuthDepartmentVo) return Response(result) except APIException as e: logging.error(e) return Response(qf.unsuccessful())
def post(self, request, *args, **kwargs): request.versioning_scheme.reverse('statamazoncategorylistset', request=request) qf = QF() try: result = qf.parseRequestToFilter(request, AmazonProductCategoryModel, StatAmazonLineVo) return Response(result) except APIException as e: print(e) return Response(qf.unsuccessful())
def post(self, request, *args, **kwargs): # 反向生成URL request.versioning_scheme.reverse('statamazonlinetotalitemsmonth', request=request) qf = QF() try: result = qf.parseRequestToFilter( request, StatAmazonLineTotalItemsMonthDv, StatAmazonLineTotalItemsMonthDvVo) return Response(result) except APIException as e: print(e) return Response(qf.unsuccessful())
def post(self, request, *args, **kwargs): auth = request.META.get('HTTP_AUTHORIZATION', b'').split() qf = QF() try: token = Token.objects.get(key=auth[1]) profile = UserProfileModel.objects.get(user=token.user) except (UserProfileModel.DoesNotExist, Token.DoesNotExist): profile = UserProfileModel() profile.user = token.user vo = UserProfileVo(instance=profile) if token is None: return Response(qf.unsuccessful()) else: return Response(qf.successful(data=vo.data))
def post(self, request, *args, **kwargs): username = request.data.get('username') password = request.data.get('password') if username and password: user = authenticate(username=username, password=password) else: msg = _('Must include "username" and "password".') raise serializers.ValidationError(msg, code='authorization') qf = QF() if user is None: msg = _('Unable to log in with provided credentials.') raise serializers.ValidationError(msg, code='authorization') else: token, created = Token.objects.get_or_create(user=user) if not created: token.key = token.generate_key() Token.objects.filter(user_id=user.id).update(key=token.key) log = ApiLog(title="用户登录", content='用户登录成功:' + user.username, action=request.get_full_path(), ip=request.META['REMOTE_ADDR'], creator_id=user.id) log.save() return Response(qf.successful({'token': token.key}))