def published_good_search(request): ''' #搜索已发布商品的方法 published_good_search ''' describe = request.POST['describe'] designer = 1 result_goods = search_handle.published_search(describe, designer) #pdb.set_trace() goods_find = [] for good_id in result_goods: good = Goods.objects.get(id=good_id) temp = { 'id': good.id, 'designer_id': good.designer_id, 'good_price': good.goods_price, 'description': good.description, 'tags': good.tags, 'style': good.style, 'stl_path': str(good.stl_path), 'preview_1': str(server_website.file_server_path) + str(good.preview_1), 'preview_2': str(server_website.file_server_path) + str(good.preview_2), 'preview_3': str(server_website.file_server_path) + str(good.preview_3), 'approval_time': good.approval_time.strftime("%Y-%m-%d"), 'file_size': good.file_size, 'collected_count': good.collected_count, 'download_count': good.download_count } goods_find.append(temp) conf = {'goods_find': goods_find} return HttpResponse(json.dumps(conf))
def published_good_search(request): """ #搜索已发布商品的方法 published_good_search """ describe = request.POST["describe"] designer = 1 result_goods = search_handle.published_search(describe, designer) # pdb.set_trace() goods_find = [] for good_id in result_goods: good = Goods.objects.get(id=good_id) temp = { "id": good.id, "designer_id": good.designer_id, "good_price": good.goods_price, "description": good.description, "tags": good.tags, "style": good.style, "stl_path": str(good.stl_path), "preview_1": str(server_website.file_server_path) + str(good.preview_1), "preview_2": str(server_website.file_server_path) + str(good.preview_2), "preview_3": str(server_website.file_server_path) + str(good.preview_3), "approval_time": good.approval_time.strftime("%Y-%m-%d"), "file_size": good.file_size, "collected_count": good.collected_count, "download_count": good.download_count, } goods_find.append(temp) conf = {"goods_find": goods_find} return HttpResponse(json.dumps(conf))
def unpublished_good_search(request): ''' #搜索商品的方法 ''' describe = request.POST['search_val'] user = request.user designer = Designer_User.objects.get(user=user).id good_state = int(request.POST['search_type']) if good_state < 3: result_goods = search_handle.unexecuteed_search( describe, designer, good_state) goods_find = [] for good_id in result_goods: good = Goods_Upload.objects.get(id=good_id) temp = { 'id': good.id, 'designer_id': good.designer_id, 'good_price': good.goods_price, 'name': good.goods_name, 'description': good.description, 'tags': good.tags, 'style': good.style, 'type': 'stl', 'stl_path': good.stl_path, 'preview_1': str(server_website.file_server_path) + str(good.preview_1), 'preview_2': str(server_website.file_server_path) + str(good.preview_2), 'preview_3': str(server_website.file_server_path) + str(good.preview_3), 'upload_time': good.upload_time.strftime("%Y-%m-%d"), 'modify_time': good.modify_time.strftime("%Y-%m-%d"), 'file_size': good.file_size, 'good_state': good.good_state, 'not_passed': good.not_passed } goods_find.append(temp) else: result_goods = search_handle.published_search(describe, designer) goods_find = [] for good_id in result_goods: good = Goods.objects.get(id=good_id) temp = { 'id': good.id, 'designer_id': good.designer_id, 'good_price': good.goods_price, 'description': good.description, 'tags': good.tags, 'style': good.style, 'stl_path': str(good.stl_path), 'preview_1': str(server_website.file_server_path) + str(good.preview_1), 'preview_2': str(server_website.file_server_path) + str(good.preview_2), 'preview_3': str(server_website.file_server_path) + str(good.preview_3), 'approval_time': good.approval_time.strftime("%Y-%m-%d"), 'file_size': good.file_size, 'collected_count': good.collected_count, 'download_count': good.download_count } goods_find.append(temp) if len(goods_find) % 2 == 1: total_pages = len(goods_find) / 2 + 1 else: total_pages = len(goods_find) / 2 conf = {'all_list': goods_find, 'total_pages': total_pages} return HttpResponse(json.dumps(conf))
def unpublished_good_search(request): """ #搜索商品的方法 """ describe = request.POST["search_val"] user = request.user designer = Designer_User.objects.get(user=user).id good_state = int(request.POST["search_type"]) if good_state < 3: result_goods = search_handle.unexecuteed_search(describe, designer, good_state) goods_find = [] for good_id in result_goods: good = Goods_Upload.objects.get(id=good_id) temp = { "id": good.id, "designer_id": good.designer_id, "good_price": good.goods_price, "name": good.goods_name, "description": good.description, "tags": good.tags, "style": good.style, "type": "stl", "stl_path": good.stl_path, "preview_1": str(server_website.file_server_path) + str(good.preview_1), "preview_2": str(server_website.file_server_path) + str(good.preview_2), "preview_3": str(server_website.file_server_path) + str(good.preview_3), "upload_time": good.upload_time.strftime("%Y-%m-%d"), "modify_time": good.modify_time.strftime("%Y-%m-%d"), "file_size": good.file_size, "good_state": good.good_state, "not_passed": good.not_passed, } goods_find.append(temp) else: result_goods = search_handle.published_search(describe, designer) goods_find = [] for good_id in result_goods: good = Goods.objects.get(id=good_id) temp = { "id": good.id, "designer_id": good.designer_id, "good_price": good.goods_price, "description": good.description, "tags": good.tags, "style": good.style, "stl_path": str(good.stl_path), "preview_1": str(server_website.file_server_path) + str(good.preview_1), "preview_2": str(server_website.file_server_path) + str(good.preview_2), "preview_3": str(server_website.file_server_path) + str(good.preview_3), "approval_time": good.approval_time.strftime("%Y-%m-%d"), "file_size": good.file_size, "collected_count": good.collected_count, "download_count": good.download_count, } goods_find.append(temp) if len(goods_find) % 2 == 1: total_pages = len(goods_find) / 2 + 1 else: total_pages = len(goods_find) / 2 conf = {"all_list": goods_find, "total_pages": total_pages} return HttpResponse(json.dumps(conf))