def post(self, aid): try: useraddr = UserAddr.get(id=aid) except: self.flash("此地址不存在") self.redirect("/user/address") return user = self.get_current_user() city = self.get_argument("city", None) region = self.get_argument("region", None) address = self.get_argument("address", None) name = self.get_argument("name", None) tel = self.get_argument("tel", "") mobile = self.get_argument("mobile", None) if city and region and address and name and mobile and vmobile(mobile): useraddr.city = city useraddr.region = region useraddr.address = address useraddr.name = name useraddr.tel = tel useraddr.mobile = mobile try: UserAddr.get(id != useraddr.id, uid=user.uid, address=address) self.flash("此地址已存在") except: try: useraddr.save() self.flash("保存成功", 'sucess') except Exception, ex: logging.error(ex) self.flash("系统出错,请稍后重试")
def post(self, aid): try: useraddr = UserAddr.get(id = aid) except: self.flash("此地址不存在") self.redirect("/user/address") return user = self.get_current_user() city = self.get_argument("city", None) region = self.get_argument("region", None) address = self.get_argument("address", None) name = self.get_argument("name", None) tel = self.get_argument("tel", "") mobile = self.get_argument("mobile", None) if city and region and address and name and mobile and vmobile(mobile): useraddr.city = city useraddr.region = region useraddr.address = address useraddr.name = name useraddr.tel = tel useraddr.mobile = mobile try: UserAddr.get(id != useraddr.id, uid = user.uid, address = address) self.flash("此地址已存在") except: try: useraddr.save() self.flash("保存成功", 'sucess') except Exception, ex: logging.error(ex) self.flash("系统出错,请稍后重试")
def get(self): user = self.get_current_user() address = [ addr for addr in UserAddr.select().where(UserAddr.uid == user.id) ] self.render('user/address.html', address=address, useraddr=UserAddr(mobile=user.mobile))
def get(self, aid): try: useraddr = UserAddr.get(id = aid) except: self.flash("此地址不存在") self.redirect("/user/address") return user = self.get_current_user() address = [addr for addr in UserAddr.select().where(UserAddr.uid == user.id)] self.render('user/address.html', address = address, useraddr = useraddr)
def get(self, uaid): result = {'status': False, 'msg': 0} user = self.get_current_user() if user: try: UserAddr.delete().where(UserAddr.id == uaid).execute() result['status'] = True result['msg'] = 200 except Exception, ex: logging.error(ex) result['msg'] = 500
def get(self, uaid): result = {'status' : False, 'msg' : 0} user = self.get_current_user() if user: try: UserAddr.delete().where(UserAddr.id == uaid).execute() result['status'] = True result['msg'] = 200 except Exception, ex: logging.error(ex) result['msg'] = 500
def get(self): status = self.get_argument("status", None) ft = (Order.status >= 0) if status: ft = ft & (Order.status == status) page = int(self.get_argument("page", 1)) pagesize = self.settings['admin_pagesize'] oq = Order.select().where(ft) total = oq.count() orders = [] for order in oq.paginate(page, pagesize).order_by( Order.ordered.desc()).dicts(): order['orderitems'] = [] try: order['ua'] = UserAddr.get(id=order['uaid']) except: order['ua'] = UserAddr() try: order['distr'] = Distribution.get(id=order['distrid']) except: order['distr'] = Distribution() for orderitem in OrderItem.select().where( OrderItem.oid == order['id']).dicts(): try: orderitem['shop'] = Shop.get(id=orderitem['sid']) if orderitem['said'] > 0: orderitem['shopattr'] = ShopAttr.get( id=orderitem['said']) order['orderitems'].append(orderitem) except: orderitem['shop'] = Shop() if order['orderitems']: orders.append(order) self.render('admin/order.html', orders=orders, total=total, page=page, pagesize=pagesize)
def get(self): user = self.get_current_user() result = [] if user: result = [useraddr for useraddr in UserAddr.select().where(UserAddr.uid == user.id).dicts()] self.write(simplejson.dumps(result))
def check_user_store_distance(_self): result = 0 user = _self.get_current_user() client_store = _self.get_secure_cookie('store', None) if client_store and user: ua = UserAddr.select().where((UserAddr.user == user.id) & (UserAddr.isdefault == 1)) if ua.count() > 0: address = ua[0].province + ua[0].city + ua[0].address s = getDistanceAS(address.replace(' ', ''), client_store) if s['flag'] == 1: if float(s['data']) < setting.PeiSongDistance: result = 1 return result
def get(self): status = self.get_argument("status", None) ft = (Order.status >= 0) if status: ft = ft & (Order.status == status) page = int(self.get_argument("page", 1)) pagesize = self.settings['admin_pagesize'] oq = Order.select().where(ft) total = oq.count() orders = [] for order in oq.paginate(page, pagesize).order_by(Order.ordered.desc()).dicts(): order['orderitems'] = [] try: order['ua'] = UserAddr.get(id = order['uaid']) except: order['ua'] = UserAddr() try: order['distr'] = Distribution.get(id = order['distrid']) except: order['distr'] = Distribution() for orderitem in OrderItem.select().where(OrderItem.oid == order['id']).dicts(): try: orderitem['shop'] = Shop.get(id = orderitem['sid']) if orderitem['said'] > 0: orderitem['shopattr'] = ShopAttr.get(id = orderitem['said']) order['orderitems'].append(orderitem) except: orderitem['shop'] = Shop() if order['orderitems']: orders.append(order) self.render('admin/order.html', orders = orders, total = total, page = page, pagesize = pagesize)
def get(self, aid): user = self.get_current_user() UserAddr.delete().where(UserAddr.uid == user.id, UserAddr.id == aid).execute() self.flash("删除成功") self.redirect("/user/address")
def post(self): result = {'status' : False, 'msg' : 0} user = self.get_current_user() if user: city = self.get_argument("city", None) region = self.get_argument("region", None) address = self.get_argument("address", None) name = self.get_argument("name", None) tel = self.get_argument("tel", "") mobile = self.get_argument("mobile", None) if city and region and address and name and mobile and vmobile(mobile): useraddr = UserAddr() useraddr.uid = user.id useraddr.city = city useraddr.region = region useraddr.address = address useraddr.name = name useraddr.tel = tel useraddr.mobile = mobile try: UserAddr.get(uid = user.uid, address = address) result['msg'] = 503 except: try: useraddr.save() result['status'] = True result['msg'] = 200 except Exception, ex: logging.error(ex) result['msg'] = 500 else: result['msg'] = 400
def post(self): result = {'status': False, 'msg': 0} user = self.get_current_user() if user: city = self.get_argument("city", None) region = self.get_argument("region", None) address = self.get_argument("address", None) name = self.get_argument("name", None) tel = self.get_argument("tel", "") mobile = self.get_argument("mobile", None) if city and region and address and name and mobile and vmobile( mobile): useraddr = UserAddr() useraddr.uid = user.id useraddr.city = city useraddr.region = region useraddr.address = address useraddr.name = name useraddr.tel = tel useraddr.mobile = mobile try: UserAddr.get(uid=user.uid, address=address) result['msg'] = 503 except: try: useraddr.save() result['status'] = True result['msg'] = 200 except Exception, ex: logging.error(ex) result['msg'] = 500 else: result['msg'] = 400
def get(self): user = self.get_current_user() address = [addr for addr in UserAddr.select().where(UserAddr.uid == user.id)] self.render('user/address.html', address = address, useraddr = UserAddr(mobile = user.mobile))