async def add_store(name: str, token: str, user_id: str) -> Store: store = Store(name=name, token=token, user_id=user_id) if hasattr(store, "id"): delattr(store, "id") ret = await db.stores.insert_one(store.dict(by_alias=True)) store.id = ret.inserted_id return store
def store_edit(request): """ 商店资料编辑 :param request: :param store_id: :return: ['name','seller','business','kinds','link','industry','character','phone','QQ','is_create','is_design','is_custom','is_work_design','company','introduction','post','connector'] """ try: user = request.user store = Store.objects.filter(status=2).get(seller=user) Aform = StoreForm(instance=store) except: return HttpResponseRedirect('/Store/store_apply') if request.method == 'POST': name = request.POST.get('name') business = request.POST.get('business') kinds = request.POST.get('kinds') link = request.POST.get('link') industry = request.POST.get('industry') character = request.POST.get('character') phone = request.POST.get('phone') QQ = request.POST.get('QQ') introduction = request.POST.get('introduction') headpicture = request.FILES.get('headpicture','') companyname = request.POST.get('companyname') connectioner = request.POST.get('connectioner') connection_number = request.POST.get('connection_number') company_adress = request.POST.get('company_adress') company_QQ = request.POST.get('company_QQ') business_license = request.FILES.get('business_license','') company_introduce = request.POST.get('company_introduce') kind = big_goods_type.objects.get(id=kinds) # 头像保存保存# 营业执照保存 if not headpicture : headpicture = store.headpicture else: path = default_storage.save(str(headpicture), ContentFile(headpicture.read())) tmp_file = os.path.join(settings.MEDIA_ROOT, path) headpicture = str(headpicture) if not business_license: business_license = store.business_license else: path = default_storage.save(str(business_license), ContentFile(business_license.read())) tmp_file = os.path.join(settings.MEDIA_ROOT, path) business_license = str(business_license) s = Store(name=name, phone=phone, QQ=QQ, link=link, kinds=kind,seller=user, business=business, industry=industry, character=character, introduction=introduction, headpicture=headpicture, companyname=companyname, connectioner=connectioner, connection_number=connection_number, company_adress=company_adress, company_QQ=company_QQ, business_license=business_license, company_introduce=company_introduce) s.id = store.id s.save() return HttpResponse('修改成功啦') else: return render(request,'person_dpbj.html',{'form':Aform}) # else: