def product_prices(self): inputParams = self.getInput() try: productsList = Products.select().where(Products.category==int(inputParams['category'])).order_by(Products.id.desc()) self.privData['PRODUCTS_LIST'] = productsList self.privData['ORDER'] = int(inputParams['order']) if inputParams.has_key('order') else -1 self.privData['CATEGORY'] = Categories.get(Categories.id==int(inputParams['category'])) return self.display('product-prices') except Exception, e: print e return self.error(msg='获取产品价格列表失败!')
def list(self): inputParams = self.getInput() page = int(inputParams['page']) if inputParams.has_key('page') else 1 count = config.COUNT_PER_PAGE productsList = Products.select().order_by(Products.id.desc()) pageString = self.getPageStr('/admin/products/list', page, count, productsList.count()) self.privData['PRODUCTS_LIST'] = productsList.paginate(page, count) self.privData['PAGE_STRING'] = pageString categoriesList = Categories().select() self.privData['CATEGORIES_LIST'] = categoriesList return self.display('productsList')
def search_by_category(self): inputParams = self.getInput() category = int(inputParams['category']) if inputParams.has_key('category') else 0 page = int(inputParams['page']) if inputParams.has_key('page') else 1 count = config.COUNT_PER_PAGE offset= (page-1)*count if page > 0 else 0 productsList = Products.select().where(Products.category == category).order_by(Products.id.desc()) pageString = self.getPageStr('/admin/products/list', page, count, productsList.count()) self.privData['PRODUCTS_LIST'] = productsList self.privData['PAGE_STRING'] = pageString categoriesList = Categories().select() self.privData['CATEGORIES_LIST'] = categoriesList return self.display('productsList')