def post(self): current_user_id = self.current_user_id url = self.get_argument('url', None) if url: if url_by_id(current_user_id): error_url = '个性域名设置后不能修改' else: error_url = url_valid(url) if error_url is None: url_new(current_user_id, url) self.redirect(SITE_URL) else: error_url = '个性域名不能为空' self.render( error_url=error_url, url=url )
def post(self): current_user_id = self.current_user_id current_user = self.current_user url = self.get_argument('url', None) if url: if url_by_id(current_user_id): error_url = '个性域名设置后不能修改' else: error_url = url_valid(url) if error_url is None: url_new(current_user_id, url) from model.autocomplete_user import autocomplete_user_url_new autocomplete_user_url_new(current_user, url) self.redirect(SITE_URL) else: error_url = '个性域名不能为空' self.render(error_url=error_url, url=url)
def post(self): current_user_id = self.current_user_id current_user = self.current_user url = self.get_argument("url", None) if url: if url_by_id(current_user_id): error_url = "个性域名设置后不能修改" else: error_url = url_valid(url) if error_url is None: url_new(current_user_id, url) from model.autocomplete_user import autocomplete_user_url_new autocomplete_user_url_new(current_user, url) self.redirect(SITE_URL) else: error_url = "个性域名不能为空" self.render(error_url=error_url, url=url)
def post(self): errtip = Errtip() current_user = self.current_user current_user_id = current_user.id name = self.get_argument('name', None) motto = self.get_argument('motto', None) url = self.get_argument('url', None) pid = self.get_arguments('pid', None) address = self.get_arguments('address', None) phone = self.get_argument('phone', None) pid_add = zip(pid, address) if not name: errtip.name = '请输入名称' if not motto: errtip.motto = '请编写签名' if url: errtip.url = url_valid(url) files = self.request.files pic_id = None if 'pic' in files: pic = files['pic'][0]['body'] pic = picopen(pic) if pic: pic_id = site_ico_new(current_user_id, pic) else: errtip.pic = '图片格式有误' else: pic_id = self.get_argument('pic_id', None) if not pic_id: errtip.pic = '请上传图片' if not errtip: com = com_new(name, current_user_id ) com_id = com.id zsite_com_new(com_id, phone=phone) site_ico_bind(current_user_id, pic_id, com_id) motto_set(com_id, motto) zsite_member_new(com_id, current_user_id, state=ZSITE_MEMBER_STATE_ACTIVE) if pid_add: for pa in pid_add: zsite_com_place_new(com_id, int(pa[0]), pa[1]) else: pid_add = self.get_argument('pid_add', None) if url: url_new(com_id, url) return self.redirect('%s/product/new'%com.link) return self.render( errtip=errtip, name=name, motto=motto, url=url, #txt=txt, phone=phone, pic_id=pic_id, pid_add=pid_add )
def _site_save(self): arguments = self.request.arguments current_user = self.current_user current_user_id = current_user.id link_cid = [] link_kv = [] errtip = Errtip() name = self.get_argument('name', None) motto = self.get_argument('motto', None) url = self.get_argument('url', None) txt = self.get_argument('txt', None) for cid, link in zip(arguments.get('cid', []), arguments.get('link', [])): cid = int(cid) link_name = SITE_LINK_ZSITE_DICT[cid] link_cid.append( (cid, link_name, linkify(link, cid)) ) for id, key, value in zip( arguments.get('id', []), arguments.get('key', []), arguments.get('value', []) ): id = int(id) link = linkify(value) link_kv.append( (id, key.strip() or urlparse(link).netloc, link) ) files = self.request.files pic_id = None if 'pic' in files: pic = files['pic'][0]['body'] pic = picopen(pic) if pic: pic_id = site_ico_new(current_user_id, pic) else: errtip.pic = '图片格式有误' else: pic_id = self.get_argument('pic_id', None) if not pic_id: errtip.pic = '请上传图片' if not name: errtip.name = '请输入名称' if not motto: errtip.motto = '请编写签名' if url: errtip.url = url_valid(url) if errtip: for cid, link_name in SITE_LINK_NAME: if cid not in set(i[0] for i in link_cid): link_cid.append( ( cid, link_name, '' ) ) return errtip, link_cid, link_kv, name, motto, url, txt, pic_id