def get_collections(request): if request.method == 'POST': r_userid = request.META.get("HTTP_USERID") r_type = request.POST.get("colType", '0') qr2 = Collect.objects.filter(authorId=r_userid).filter(colType=r_type) return JsonResponse(common.build_model_list(qr2), safe=False) if request.method == 'GET': r_userid = request.META.get("HTTP_USERID") r_type = request.GET.get("colType", '0') qr2 = Collect.objects.filter(authorId=r_userid).filter(colType=r_type) return JsonResponse(common.build_model_list(qr2), safe=False)
def get_user_blogs(request): r_userid = request.META.get("HTTP_USERID") pageNum = 1 if request.method == 'POST': pageNum = request.POST.get("page", '1') if request.method == 'GET': pageNum = request.GET.get("page", '1') if pageNum == 0: pageNum = 1 qr = MicroBlog.objects.all().filter(authorId=r_userid).filter(isDeleted=0).order_by( "-createTime") pt = paginator.Paginator(qr, 50) try: pages = pt.page(pageNum) tmp_pride = Pride.objects.filter(authorId=r_userid) tmp_col = Collect.objects.filter(authorId=r_userid) for d in pages: if isinstance(d, MicroBlog): if len(tmp_pride.filter(blogId=d.blogId)) > 0: d.isPrided = MicroBlog.HAVE if len(tmp_col.filter(itemId=d.blogId)) > 0: d.isCollected = MicroBlog.HAVE return JsonResponse(common.build_model_list(pages), safe=False) except: return JsonResponse(common.build_result(CLIENT_ERROR, "没有更多数据"), safe=False)
def get_comments(request): r_parentid = "" if request.method == 'POST': r_parentid = request.POST.get("parentId", '') if request.method == 'GET': r_parentid = request.GET.get("parentId", '') qr = Comment.objects.filter(parentId=r_parentid).order_by("-createTime") return JsonResponse(common.build_model_list(qr), safe=False)
def allusers(request): if request.method == 'POST': admintoken = request.POST.get("admintoken", '0') pageNum = request.POST.get("page", '1') if admintoken == "I am cysion": qr = User.objects.all() pt = paginator.Paginator(qr, 10) pages = pt.page(pageNum) return JsonResponse(common.build_model_list(pages), safe=False) return JsonResponse(common.build_result(CLIENT_ERROR, ERROR_REQ_METHOD), safe=False)
def get_looper(request): cr = Looper.objects.all() return JsonResponse(common.build_model_list(cr), safe=False)