def redirect_distribute_lab_orders(request, parameters=''): _form_data = {} _items = [] rm = response_message() rm.code = 0 dh = dict_helper() try: rm.obj = 'ok' lab_number = request.POST.get('lab_number', '') paras = {} paras['pa'] = parameters paras['user'] = request.user lbo = LabOrder.objects.get(lab_number=lab_number) paras['lbo'] = lbo dc = distribute_controller() rm = dc.distribute_vendor(lbo, paras) except Exception as e: _rm.capture_execption(e) json_body = dh.convert_to_dict(rm) json_body = json.dumps(json_body, cls=DateEncoder) return HttpResponse(json_body)
def redirect_lens_by_vd(request, parameters=''): _form_data = {} rm = response_message() dh = dict_helper() try: if request.method == 'POST': logging.debug('收到请求 ....') logging.debug(AUTHOR) entity = parameters parameters = {} vendor = request.POST.get('vendor', '') index = request.POST.get('index', '') if vendor == '2': vendor = '3' if vendor == '0': vendor = '' if vendor == '9': vendor = '5' parameters['vendor'] = vendor parameters['index'] = index rm_req = response_message() rm_req.obj = parameters lc = lens_contoller() rm = lc.get_by_vd(rm_req) objs = rm.obj vendor_lens_list = [] for obj in objs: vendor_lens = {} vendor_lens['sku'] = obj.sku vendor_lens['name'] = obj.name vendor_lens_list.append(vendor_lens) logging.debug(obj.sku) rm.obj = vendor_lens_list json_body = dh.convert_to_dict(rm) logging.debug(json_body) json_body = json.dumps(json_body, cls=DateEncoder) logging.debug(json_body) return HttpResponse(json_body) lc = lens_contoller() rm = lc.get_all(parameters) _form_data['list'] = rm.obj except Exception as e: rm.capture_execption(e) json_body = dh.convert_to_dict(rm) json_body = json.dumps(json_body, cls=DateEncoder) return HttpResponse(json_body) return render(request, "lens_all.html", {"form": _form_data})
def redirect_lens(request, parameters=''): _form_data = {} rm = response_message() dh = dict_helper() try: if request.method == 'POST': entity = parameters parameters = {} parameters['entity'] = entity lc = lens_contoller() rm = lc.get_all(parameters) json_body = dh.convert_to_dict(rm) json_body = json.dumps(json_body, cls=DateEncoder) return HttpResponse(json_body) lc = lens_contoller() rm = lc.get_all(parameters) _form_data['list'] = rm.obj # 获取页码 page = request.GET.get('page', 1) # 获取URL中除page外的其它参数 import re query_string = re.sub(r'page=[0-9]+[&]?', '', request.META.get('QUERY_STRING', None)) if query_string: query_string = '&' + query_string # 分页对象,设置每页20条数据 paginator = Paginator(_form_data['list'], 20) try: contacts = paginator.page(page) except PageNotAnInteger: # If page is not an integer, deliver first page. contacts = paginator.page(1) except EmptyPage: # If page is out of range (e.g. 9999), deliver last page of results. contacts = paginator.page(paginator.num_pages) except Exception as e: rm.capture_execption(e) json_body = dh.convert_to_dict(rm) json_body = json.dumps(json_body, cls=DateEncoder) return HttpResponse(json_body) return render( request, "lens_all.html", { "form": _form_data, 'list': contacts, 'paginator': paginator, 'query_string': query_string, })
def redirect_lens_orders(request, parameters=''): _form_data = {} rm = response_message() dh = dict_helper() try: page = request.GET.get('page', 1) currentPage = int(page) loc = lens_order_contoller() rm = loc.get_all(parameters) items = rm.obj _form_data['list'] = items _form_data['total'] = rm.count paginator = Paginator(items, 20) # Show 20 contacts per page # 获取URL中除page外的其它参数 import re query_string = re.sub(r'page=[0-9]+[&]?', '', request.META.get('QUERY_STRING', None)) if query_string: query_string = '&' + query_string try: items = paginator.page(page) except PageNotAnInteger: # If page is not an integer, deliver first page. items = paginator.page(1) except EmptyPage: # If page is out of range (e.g. 9999), deliver last page of results. items = paginator.page(paginator.num_pages) except Exception as e: rm.capture_execption(e) # json_body = dh.convert_to_dict(rm) # json_body = json.dumps(json_body, cls=DateEncoder) # return HttpResponse(json_body) return render( request, "lens_orders.html", { "form": _form_data, 'list': items, 'currentPage': currentPage, 'paginator': paginator, 'requestUrl': reverse('lens_orders'), 'query_string': query_string, })
def redirect_tasks(request, parameters=''): _form_data = {} rm = response_message() dh = dict_helper() try: if request.method == 'POST': entity = parameters parameters = {} parameters['entity'] = entity _form_data['list'] = rm.obj except Exception as e: rm.capture_execption(e) json_body = dh.convert_to_dict(rm) json_body = json.dumps(json_body, cls=DateEncoder) return HttpResponse(json_body) return render(request, "tasks.html", {"form": _form_data})
def redirect_distribute_lab_orders_manual_quick(request, parameters=''): _form_data = {} rm = response_message() dh = dict_helper() try: if request.method == 'POST': logging.debug('收到请求 ....') parameters = {} parameters['request'] = request lab_number = request.POST.get('lab_number', '') logging.debug('lab_number: %s' % lab_number) lbo = LabOrder.objects.get(lab_number=lab_number) parameters['lbo'] = lbo parameters['lab_number'] = lab_number parameters['modify'] = 'MANUAL' parameters['vendor'] = request.POST.get('vendor', '') parameters['lens_sku'] = request.POST.get('lens_sku', '') parameters['lens_name'] = request.POST.get('lens_name', '') parameters['user'] = request.user qualified = request.POST.get('qualified', '') if qualified == '1': is_qualified = True else: is_qualified = False if is_qualified: parameters['qualified'] = is_qualified logging.debug('lens_name: %s' % parameters['lens_name']) logging.debug(parameters) dc = distribute_controller() rm = dc.distribute_vendor_manual(parameters) logging.debug(rm.code) json_body = dh.convert_to_dict(rm) json_body = json.dumps(json_body, cls=DateEncoder) logging.debug(json_body) return HttpResponse(json_body) else: lab_number = request.GET.get('lab_number', '') qualified = request.GET.get('qualified', '') # lc = lens_contoller() # rm = lc.get_all(parameters) # _form_data['list'] = rm.obj lbo = LabOrder.objects.get(lab_number=lab_number) _form_data['laborder'] = lbo if qualified == '1': _form_data['code'] = 0 _form_data['message'] = "【初检合格】操作成功!" else: _form_data['code'] = 0 _form_data['message'] = "【初检不合格】操作成功!" return render(request, "construction_voucher_finished_glasses_quick.html", { 'form_data': _form_data, }) except Exception as e: rm.capture_execption(e) json_body = dh.convert_to_dict(rm) json_body = json.dumps(json_body, cls=DateEncoder) return HttpResponse(json_body) return render(request, "lens_all.html", {"form": _form_data})
def redirect_distribute_lab_orders_manual(request, parameters=''): _form_data = {} rm = response_message() dh = dict_helper() try: if request.method == 'POST': logging.debug('收到请求 ....') logging.debug(AUTHOR) parameters = {} parameters['request'] = request lab_number = request.POST.get('lab_number', '') vendor = request.POST.get('vendor', '') lens_sku = request.POST.get('lens_sku', '') lens_name = request.POST.get('lens_name', '') logging.debug('lab_number: %s' % lab_number) lbo = LabOrder.objects.get(lab_number=lab_number) logging.debug(vendor) logging.debug(lbo.status) if vendor in ['1000', '1001']: if (lbo.status == 'SHIPPING' or lbo.status == 'DELIVERED' or lbo.status == 'CANCELLED' or lbo.status == 'CLOSED'): rm.code = -3 rm.message = '当前状态是【%s】不允许修改VD' % lbo.status json_body = dh.convert_to_dict(rm) json_body = json.dumps(json_body, cls=DateEncoder) return HttpResponse(json_body) lbo.vendor = vendor lbo.save() tloc = tracking_lab_order_controller() tloc.tracking(lbo, request.user, 'MANUAL', '手动分单', '手动分单vd' + vendor) json_body = dh.convert_to_dict(rm) json_body = json.dumps(json_body, cls=DateEncoder) return HttpResponse(json_body) else: parameters['lbo'] = lbo parameters['lab_number'] = lab_number parameters['modify'] = 'MANUAL' parameters['vendor'] = vendor parameters['lens_sku'] = lens_sku parameters['lens_name'] = lens_name parameters['user'] = request.user qualified = request.POST.get('qualified', '') if qualified == '1': is_qualified = True else: is_qualified = False if is_qualified: parameters['qualified'] = is_qualified logging.debug('lens_name: %s' % parameters['lens_name']) logging.debug(parameters) dc = distribute_controller() rm = dc.distribute_vendor_manual(parameters) logging.debug(rm.code) json_body = dh.convert_to_dict(rm) json_body = json.dumps(json_body, cls=DateEncoder) logging.debug(json_body) return HttpResponse(json_body) lc = lens_contoller() rm = lc.get_all(parameters) _form_data['list'] = rm.obj except Exception as e: rm.capture_execption(e) json_body = dh.convert_to_dict(rm) json_body = json.dumps(json_body, cls=DateEncoder) return HttpResponse(json_body) return render(request, "lens_all.html", {"form": _form_data})