def get(self): ads = Ad.select().limit(6) newest = [] for shop in Shop.select( Shop.name, Shop.ename, Shop.cover, Shop.price).where((Shop.cid != 2) & (Shop.status != 9)).order_by( Shop.views.desc()).limit(6): shop.price = shop.price.split("~")[0] newest.append(shop) recomm = [] for shop in Shop.select(Shop.name, Shop.ename, Shop.cover, Shop.price).where(Shop.status == 1).limit(6): shop.price = shop.price.split("~")[0] recomm.append(shop) ccategory = None keyword = self.get_argument("keyword", None) page = int(self.get_argument("page", 1)) order = self.get_argument("order", None) pagesize = self.settings['admin_pagesize'] categorys = self.get_categorys() sq = Shop.select(Shop.name, Shop.ename, Shop.cover, Shop.price) total = sq.count() if ccategory: sq = sq.where((Shop.cid == ccategory.id) & (Shop.status != 9)) elif keyword: keyword = "%" + keyword + "%" sq = sq.where((Shop.name % keyword) & (Shop.status != 9)) else: sq = sq.where((Shop.cid != 2) & (Shop.status != 9)) if order: sq = sq.order_by(Shop.orders.desc()) else: sq = sq.order_by(Shop.views.desc()) shops = [] for shop in sq.paginate(page, pagesize): shop.price = shop.price.split("~")[0] shops.append(shop) self.render("responsive/index.html", ads=ads, newest=newest, recomm=recomm, ccategory=ccategory, categorys=categorys, shops=shops, total=total, page=page, pagesize=pagesize)
def get(self): ads = Ad.select().limit(6) newest = [] for shop in Shop.select(Shop.name, Shop.ename, Shop.cover, Shop.price).where((Shop.cid != 2) & (Shop.status != 9)).order_by(Shop.views.desc()).limit(6): shop.price = shop.price.split("~")[0] newest.append(shop) recomm = [] for shop in Shop.select(Shop.name, Shop.ename, Shop.cover, Shop.price).where(Shop.status == 1).limit(6): shop.price = shop.price.split("~")[0] recomm.append(shop) self.render("site/index.html", ads = ads, newest = newest, recomm = recomm)
def get(self): page = int(self.get_argument("page", 1)) cid = int(self.get_argument("cid", 0)) status = int(self.get_argument("status", 0)) pagesize = self.settings['admin_pagesize'] categorys = self.get_categorys() sq = Shop.select() if cid > 0: sq = sq.where(Shop.cid == cid) if status > 0: sq = sq.where(Shop.status == status) total = sq.count() shops = sq.paginate(page, pagesize) self.render('admin/shop.html', categorys=categorys, shops=shops, total=total, page=page, pagesize=pagesize)
def get(self, ename): try: shop = Shop.get(ename=ename) shop.views = shop.views + 1 shop.save() category = Category.get(id=shop.cid) except: raise HTTPError(404) return categoryattrs = CategoryAttr.select().where( CategoryAttr.cid == shop.cid) shopattrs = ShopAttr.select().where(ShopAttr.sid == shop.id) if shop.args: shop.args = simplejson.loads(shop.args) pics = ShopPic.select().where(ShopPic.sid == shop.id) recomshops = Shop.select().where((Shop.status == 1) & (Shop.id != shop.id)).paginate( 1, 5) self.render("shop/shop.html", shop=shop, category=category, categoryattrs=categoryattrs, shopattrs=shopattrs, pics=pics, recomshops=recomshops)
def get(self): orderitems = [] user = self.current_user try: order = Order.get(uid=user.id, status=0) 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']) orderitems.append(orderitem) except: pass except: order = Order() ashops = Shop.select().where((Shop.cid == 2) & (Shop.status != 9)) self.render("shop/order.html", orderitems=orderitems, order=order, ashops=ashops)
def get(self): ads = Ad.select().limit(6) newest = [] for shop in Shop.select( Shop.name, Shop.ename, Shop.cover, Shop.price).where((Shop.cid != 2) & (Shop.status != 9)).order_by( Shop.views.desc()).limit(6): shop.price = shop.price.split("~")[0] newest.append(shop) recomm = [] for shop in Shop.select(Shop.name, Shop.ename, Shop.cover, Shop.price).where(Shop.status == 1).limit(6): shop.price = shop.price.split("~")[0] recomm.append(shop) self.render("site/index.html", ads=ads, newest=newest, recomm=recomm)
def get(self): page = int(self.get_argument("page", 1)) pagesize = self.settings['admin_pagesize'] sq = Shop.select(Shop.name, Shop.ename, Shop.cover, Shop.price).where(Shop.status == 1) total = sq.count() shops = sq.paginate(page, pagesize) self.render("shop/recomm.html", shops = shops, total = total, page = page, pagesize = pagesize)
def get(self): ads = Ad.select().limit(6) newest = [] for shop in Shop.select(Shop.name, Shop.ename, Shop.cover, Shop.price).where((Shop.cid != 2) & (Shop.status != 9)).order_by(Shop.views.desc()).limit(6): shop.price = shop.price.split("~")[0] newest.append(shop) recomm = [] for shop in Shop.select(Shop.name, Shop.ename, Shop.cover, Shop.price).where(Shop.status == 1).limit(6): shop.price = shop.price.split("~")[0] recomm.append(shop) ccategory= None keyword = self.get_argument("keyword", None) page = int(self.get_argument("page", 1)) order = self.get_argument("order", None) pagesize = self.settings['admin_pagesize'] categorys = self.get_categorys() sq = Shop.select(Shop.name, Shop.ename, Shop.cover, Shop.price) total = sq.count() if ccategory: sq = sq.where((Shop.cid == ccategory.id) & (Shop.status != 9)) elif keyword: keyword = "%" + keyword + "%" sq = sq.where((Shop.name % keyword) & (Shop.status != 9)) else: sq = sq.where((Shop.cid != 2) & (Shop.status != 9)) if order: sq = sq.order_by(Shop.orders.desc()) else: sq = sq.order_by(Shop.views.desc()) shops = [] for shop in sq.paginate(page, pagesize): shop.price = shop.price.split("~")[0] shops.append(shop) self.render("responsive/index.html", ads = ads, newest = newest, recomm = recomm,ccategory = ccategory, categorys = categorys, shops = shops, total = total, page = page, pagesize = pagesize)
def get(self): page = int(self.get_argument("page", 1)) pagesize = self.settings['admin_pagesize'] sq = Shop.select(Shop.name, Shop.ename, Shop.cover, Shop.price).where(Shop.status == 1) total = sq.count() shops = sq.paginate(page, pagesize) self.render("shop/recomm.html", shops=shops, total=total, page=page, pagesize=pagesize)
def get(self, slug): ccategory = None if slug: try: ccategory = Category.get(slug=slug) except: self.redirect("/list/") return keyword = self.get_argument("keyword", None) page = int(self.get_argument("page", 1)) order = self.get_argument("order", None) pagesize = self.settings['admin_pagesize'] categorys = self.get_categorys() sq = Shop.select(Shop.name, Shop.ename, Shop.cover, Shop.price) total = sq.count() if ccategory: sq = sq.where((Shop.cid == ccategory.id) & (Shop.status != 9)) elif keyword: keyword = "%" + keyword + "%" sq = sq.where((Shop.name % keyword) & (Shop.status != 9)) else: sq = sq.where((Shop.cid != 2) & (Shop.status != 9)) if order: sq = sq.order_by(Shop.orders.desc()) else: sq = sq.order_by(Shop.views.desc()) shops = [] for shop in sq.paginate(page, pagesize): shop.price = shop.price.split("~")[0] shops.append(shop) self.render("shop/list.html", ccategory=ccategory, categorys=categorys, shops=shops, total=total, page=page, pagesize=pagesize)
def get(self, ename): try: shop = Shop.get(ename = ename) shop.views = shop.views + 1 shop.save() category = Category.get(id = shop.cid) except: raise HTTPError(404) return categoryattrs = CategoryAttr.select().where(CategoryAttr.cid == shop.cid) shopattrs = ShopAttr.select().where(ShopAttr.sid == shop.id) if shop.args: shop.args = simplejson.loads(shop.args) pics = ShopPic.select().where(ShopPic.sid == shop.id) recomshops = Shop.select().where((Shop.status == 1) & (Shop.id != shop.id)).paginate(1, 5) self.render("shop/shop.html", shop = shop, category = category, categoryattrs = categoryattrs, shopattrs = shopattrs, pics = pics, recomshops = recomshops)
def get(self): orderitems = [] user = self.current_user try: order = Order.get(uid = user.id, status = 0) 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']) orderitems.append(orderitem) except: pass except: order = Order() ashops = Shop.select().where((Shop.cid == 2) & (Shop.status != 9)) self.render("shop/order.html", orderitems = orderitems, order = order, ashops = ashops)
def get(self): page = int(self.get_argument("page", 1)) cid = int(self.get_argument("cid", 0)) status = int(self.get_argument("status", 0)) pagesize = self.settings['admin_pagesize'] categorys = self.get_categorys() sq = Shop.select() if cid > 0: sq = sq.where(Shop.cid == cid) if status > 0: sq = sq.where(Shop.status == status) total = sq.count() shops = sq.paginate(page, pagesize) self.render('admin/shop.html', categorys = categorys, shops = shops, total = total, page = page, pagesize = pagesize)
def get(self, slug): ccategory= None if slug: try: ccategory = Category.get(slug = slug) except: self.redirect("/list/") return keyword = self.get_argument("keyword", None) page = int(self.get_argument("page", 1)) order = self.get_argument("order", None) pagesize = self.settings['admin_pagesize'] categorys = self.get_categorys() sq = Shop.select(Shop.name, Shop.ename, Shop.cover, Shop.price) total = sq.count() if ccategory: sq = sq.where((Shop.cid == ccategory.id) & (Shop.status != 9)) elif keyword: keyword = "%" + keyword + "%" sq = sq.where((Shop.name % keyword) & (Shop.status != 9)) else: sq = sq.where((Shop.cid != 2) & (Shop.status != 9)) if order: sq = sq.order_by(Shop.orders.desc()) else: sq = sq.order_by(Shop.views.desc()) shops = [] for shop in sq.paginate(page, pagesize): shop.price = shop.price.split("~")[0] shops.append(shop) self.render("shop/list.html", ccategory = ccategory, categorys = categorys, shops = shops, total = total, page = page, pagesize = pagesize)