def POST(self): name=web.input().get("name") _tags=web.input().get("tags") source=web.input().get("source") if _tags: tags=[x for x in _tags.split(",")] else: tags=[] user=User.objects(id=Auth.uid()).first() creatorID=user.ID intro=web.input().get("intro") picurl=web.input().get("picurl",None) price=web.input().get("price") link=web.input().get("source") store=get_store("store") price=web.input().get("price") buyinfo=Buy_info(link=link,store=store,price=price) #check if none pic=urllib2.urlopen(picurl).read() ID=Node.objects.count()+1 open(str(ID)+".jpg","wb").write(pic) u = UpYun(BUCKETNAME,USER,PASSWORD) data = open(str(ID)+".jpg",'rb') u.setContentMD5(md5file(data)) a = u.writeFile('/o'+str(ID)+'.jpg',data) if not a: return "get picture erro" #cut_item_picture(STATIC_FILE,ID,str(ID)+".jpg") node=Node(creatorID=creatorID,ID=ID,name=name,des=intro,picurl=picurl,tags=tags,buy_info=[buyinfo]) node.picinfo=101 #a out sidelink node.save() share=Share_items(ID=Share_items.objects.count()+1,creatorID=user.ID,itemID=ID,flag=1,content="") share.save() #加入到shareitem中 #todo count更新 tweet=Tweet(ID=Tweet.objects.count()+1,AutherID=user.ID,SubjectID=ID,flag=1,content=str(ID)) tweet.save() return web.seeother("/item/"+str(ID)+"/")
def POST(self): picurl=web.input().get("check") name=web.input().get("name") _tags=web.input().get("tags") source=web.input().get("source") if _tags: tags=[x for x in _tags.split(",")] else: tags=[] user=User.objects(id=Auth.uid()).first() creatorID=user.ID intro=web.input().get("intro") price=web.input().get("price") link=web.input().get("source") store=web.input().get("store") #store=get_store(link).decode("utf-8") price=web.input().get("price") buyinfo=Buy_info(link=link,store=store,price=price) pic=urllib2.urlopen(picurl).read() ID=Node.objects.count()+1 open(str(ID)+".jpg","wb").write(pic) u = UpYun(BUCKETNAME,USER,PASSWORD) data = open(str(ID)+".jpg",'rb') u.setContentMD5(md5file(data)) a = u.writeFile('/o'+str(ID)+'.jpg',data) if not a: return "get picture erro" #cut_item_picture(STATIC_FILE,ID,str(ID)+".jpg") node=Node(creatorID=creatorID,ID=ID,name=name,des=intro,picurl=picurl,tags=tags,buy_info=[buyinfo]) node.picinfo=101 #a out sidelink node.save() share=Share_items(ID=Share_items.objects.count()+1,creatorID=user.ID,itemID=ID,flag=1,content="") share.save() content=u'''<h1>发布成功</h1><p>你可以<a href="/item/%s/">去看看</a>或者 <a href="%s">回到刚才的逛的</a>'''%(str(ID),source) return render.info(content=content) return web.seeother("/item/"+str(ID)+"/")