def list_del(request): status="error" filter_params_dict = {} update_params_dict = {} company_name=request.POST.get("company_name") print(company_name) if company_name!="": filter_params_dict.update({"company_name":company_name}) update_params_dict.update({"flags":0}) company_obj = new_company.objects(**filter_params_dict).update(upsert= True, **update_params_dict) if company_obj: status="success" return JsonResponse({'status': status})
def add_contects(request): update_params_dict = {} status='error' type = '' print(request.GET.items) for key, value in request.GET.items(): if key =='company_name': global company_name#声明全局变量 company_name=value#赋值 else: update_params_dict.update({key: value}) print(update_params_dict) if "new_contectsName" in update_params_dict : query_set=new_company.objects.filter(contacts_name=company_name)#等号前面是数据库的字段名称,后面是传值 print(query_set) NewContect_dict =query_set._collection_obj.find(query_set._query) data_json=dumps(NewContect_dict, ensure_ascii=False) remark_dict=(json.loads(data_json))[0] del remark_dict['_id'] comment_new = remark_dict.pop("new_contects") new_contectsName =update_params_dict.get('new_contectsName') print(new_contectsName) new_contectsJob=update_params_dict.get('new_contectsJob') new_contectsTel=update_params_dict.get('new_contectsTel') new_contectsEmall=update_params_dict.get('new_contectsEmall') new_contectsLine=update_params_dict.get('new_contectsLine') new_contectsOther=update_params_dict.get('new_contectsOther') new_contectsRemark=update_params_dict.get('new_contectsRemark') if new_contectsName !='': New_contect = new_contect(new_contectsName=new_contectsName, new_contectsJob=new_contectsJob, new_contectsTel=new_contectsTel, new_contectsEmall=new_contectsEmall, new_contectsLine=new_contectsLine, new_contectsOther=new_contectsOther, new_contectsRemark=new_contectsRemark ) candidate_obj = new_company.objects(**remark_dict).update(upsert= True, **remark_dict, push__new_contects=New_contect) print(candidate_obj) status="success" return HttpResponse(status) return render(request,'client_html/company_html/add_contects.html')
def company_exid(request): filter_params_dict = {} one_params_dict = {} update_params_dict = {} status = 'error' for key, value in request.POST.items(): if "exid_list" in key: key_list = key.split("[") # exid_list,0],company_name] key2 = (key_list[2])[:-1] #company_name one_params_dict.update({key2: value}) if key == "company_name": global company_name company_name = value if one_params_dict != {}: query_set = new_company.objects.filter(company_name=company_name) company_info = query_set._collection_obj.find(query_set._query) data_json = dumps(company_info, ensure_ascii=False) company_dict = (json.loads(data_json))[0] #del company_dict['_id'] print(company_dict) dict_key = company_dict.keys() one_key = one_params_dict.keys() #判断是第几个联系人 for i in one_key: if i in dict_key: update_params_dict.update(i, one_params_dict[i]) # company_dict.update({i:item}) else: index = int(i[-1]) contect = company_dict['new_contects'] contect_dict = contect[index] if i[:-1] in contect_dict: new_key = i[:-1] contect_dict.update({new_key: one_params_dict[i]}) contect[index] = contect_dict update_params_dict.update({"new_contects": contect}) print(update_params_dict) filter_params_dict.update({"company_name": company_name}) print(filter_params_dict) company_obj = new_company.objects(**filter_params_dict).update( upsert=True, **update_params_dict) print(11111) return HttpResponse(status)
def list_exid(request): filter_params_dict = {} update_params_dict = {} status="error" for key, value in request.POST.items(): print(key) key_list=key.split("[") new_key=(key_list[2])[:-1] print(value) if new_key=="ID": filter_params_dict.update({new_key: value}) else: update_params_dict.update({new_key: value}) print(filter_params_dict) print(update_params_dict) company_obj = new_company.objects(update_params_dict).update(upsert= True, **update_params_dict) print("11111") status="success" return JsonResponse({'status': status})