def index(): resp_data = {} query = Contribution.query query.count() # 这个就是取得总的页数 req = request.values page = int(req['p']) if ('p' in req and req['p']) else 1 page_params = { 'total': query.count(), 'page_size': app.config['PAGE_SIZE'], 'page': page, 'display': app.config['PAGE_DISPLAY'], 'url': request.full_path.replace("&p={}".format(page), "") } pages = iPagination(page_params) offset = (page - 1) * app.config['PAGE_SIZE'] limit = app.config['PAGE_SIZE'] * page if 'status' in req and int(req['status']) > -1: # 顺序为1,倒序为2 if int(req['status']) == 1: list = query.order_by(Contribution.created_time.asc()).all()[offset:limit] else: list = query.order_by(Contribution.created_time.desc()).all()[offset:limit] else: list = query.order_by(Contribution.id.asc()).all()[offset:limit] resp_data['list'] = list resp_data['pages'] = pages resp_data['search_con'] = req resp_data['order'] = app.config['ORDER'] resp_data['current'] = 'index' return ops_render("feedback/index.html",resp_data)
def index(): resp_data = {} query = News.query query.count() #这个就是取得总的页数 req = request.values page = int(req['p']) if ('p' in req and req['p']) else 1 if 'mix_kw' in req: rule = or_(News.title.ilike("%{0}%".format(req['mix_kw'])), News.id.ilike("%{0}%".format(req['mix_kw']))) query = query.filter(rule) if 'status' in req and int(req['status']) > -1: query = query.filter(News.status == int(req['status'])) page_params = { 'total': query.count(), 'page_size': app.config['PAGE_SIZE'], 'page': page, 'display': app.config['PAGE_DISPLAY'], 'url': request.full_path.replace("&p={}".format(page), "") } pages = iPagination(page_params) offset = (page - 1) * app.config['PAGE_SIZE'] limit = app.config['PAGE_SIZE'] * page list = query.order_by(News.id.asc()).all()[offset:limit] resp_data['list'] = list resp_data['pages'] = pages resp_data['current'] = 'bulletin' resp_data['search_con'] = req resp_data['status_mapping'] = app.config['STATUS_MAPPING'] return ops_render("index/index.html", resp_data)
def index(): resp_data = {} req = request.values page = int(req['p']) if ('p' in req and req['p']) else 1 if "mix_kw" in req: rule = or_(User.nickname.ilike("%{0}%".format(req['mix_kw'])), User.mobile.ilike("%{0}%".format(req['mix_kw']))) User.query = User.query.filter(rule) if "status" in req and int(req['status']) > -1: User.query = User.query.filter(User.status == int(req['status'])) page_params = { 'total': User.query.count(), #总共多少数据 'page_size': app.config['PAGE_SIZE'], #每一页多少 'page': page, #第几页 'display': app.config['PAGE_DISPLAY'], #显示多少页 'url': request.full_path.replace("&p={}".format(page), "") } pages = iPagination(page_params) offset = (page - 1) * app.config['PAGE_SIZE'] limit = app.config['PAGE_SIZE'] * page #[offset:limit]切片操作,取从offset到limit的数据。 list = User.query.order_by(User.uid.desc()).all()[offset:limit] resp_data['list'] = list resp_data['pages'] = pages resp_data['search_con'] = req resp_data['status_mapping'] = app.config['STATUS_MAPPING'] for tmp in resp_data['status_mapping']: app.logger.info(tmp) return ops_render("account/index.html", resp_data)
def list(): resp_data = {} query = Books.query query.count() # 这个就是取得总的页数 req = request.values lib_location=app.config['LIB_LOCATION'] page = int(req['p']) if ('p' in req and req['p']) else 1 #将字符类型的book_type转换为int类型 if 'mix_kw' in req: rule = or_(Books.title.ilike("%{0}%".format(req['mix_kw'])), Books.author.ilike("%{0}%".format(req['mix_kw']))) query = query.filter(rule) if 'status' in req and int(req['status']) > -1: query = query.filter(Books.status == int(req['status'])) if 'cat' in req and int(req['cat']) > -1: query = query.filter(Books.book_type == int(req['cat'])) if 'location' in req and int(req['location']) > -1: query = query.filter(Books.location==lib_location[req['location']]) page_params = { 'total': query.count(), 'page_size': app.config['PAGE_SIZE'], 'page': page, 'display': app.config['PAGE_DISPLAY'], 'url': request.full_path.replace("&p={}".format(page), "") } pages = iPagination(page_params) offset = (page - 1) * app.config['PAGE_SIZE'] limit = app.config['PAGE_SIZE'] * page list = query.order_by(Books.id.asc()).all()[offset:limit] #将int类型book_type转换为str类型 books_type = app.config['BOOK_TYPES'] for item in list: type_int=item.book_type type=str(type_int) type_str=books_type[type] item.book_type=type_str resp_data['list'] = list resp_data['pages'] = pages resp_data['search_con'] = req resp_data['status_mapping'] = app.config['STATUS_MAPPING'] resp_data['book_types'] = app.config['BOOK_TYPES'] resp_data['lib_location'] = app.config['LIB_LOCATION'] #return ops_render("books_lib/index.html",{"current":"Academic_communication"}) return ops_render("books_lib/index.html",resp_data)
def check_speeches(): resp_data = {} query = Speeches.query query.count() #这个就是取得总的页数 req = request.values page = int(req['p']) if ('p' in req and req['p']) else 1 if 'mix_kw' in req: rule = or_(Speeches.title.ilike("%{0}%".format(req['mix_kw'])), Speeches.id.ilike("%{0}%".format(req['mix_kw']))) query = query.filter(rule) if 'status' in req and int(req['status']) > -1: query = query.filter(Speeches.status == int(req['status'])) page_params = { 'total': query.count(), 'page_size': app.config['PAGE_SIZE'], 'page': page, 'display': app.config['PAGE_DISPLAY'], 'url': request.full_path.replace("&p={}".format(page), "") } pages = iPagination(page_params) offset = (page - 1) * app.config['PAGE_SIZE'] limit = app.config['PAGE_SIZE'] * page list = query.order_by(Speeches.id.asc()).all()[offset:limit] #这里是想解决展示的编号问题,先放这里算了 i = 0 li = [] while i < len(list): li.append(i) i = i + 1 resp_data['list'] = list resp_data['pages'] = pages resp_data['sort'] = li resp_data['current'] = 'speeches_management' resp_data['search_con'] = req resp_data['status_mapping'] = app.config['STATUS_MAPPING'] return ops_render("dong_tai/speeches.html", resp_data)
def index(): resp_data = {} req = request.values page= int(req['page']) if ('page' in req and req['page']) else 1 query = User.query query.count() page_params = { 'total':query.count(), 'page_size':app.config['PAGE_SIZE'], 'page':page, 'display':app.config['PAGE_DISPLAY'], 'url': '/account/index' } pages = iPagination(page_params) offset = (page-1)*app.config['PAGE_SIZE'] limit = app.config['PAGE_SIZE']*page list = query.order_by(User.uid.desc()).all()[offset:limit] resp_data['list'] = list resp_data['pages'] = pages return ops_render("account/index.html",resp_data)
def back(): resp_data = {} query = Lending.query query.count() # 这个就是取得总的页数 req = request.values page = int(req['p']) if ('p' in req and req['p']) else 1 # if 'mix_kw' in req: # rule = or_(Lending.title.ilike("%{0}%".format(req['mix_kw'])), # Lending.lending_name.ilike("%{0}%".format(req['mix_kw']))) # query = query.filter(rule) # if 'status' in req and int(req['status']) > -1: # query = query.filter(Lending.status == int(req['status'])) page_params = { 'total': query.count(), 'page_size': app.config['PAGE_SIZE'], 'page': page, 'display': app.config['PAGE_DISPLAY'], 'url': request.full_path.replace("&p={}".format(page), "") } pages = iPagination(page_params) offset = (page - 1) * app.config['PAGE_SIZE'] limit = app.config['PAGE_SIZE'] * page #这里进行条件查询,查询逾期未还的 list = query.filter(Lending.status == 1).all()[offset:limit] resp_data['list'] = list resp_data['pages'] = pages #resp_data['search_con'] = req #resp_data['status_mapping'] = app.config['STATUS_MAPPING'] resp_data['current'] = 'back' resp_data['cur_date'] = getCurrentDate() return ops_render("member/back.html", resp_data)
def feedback(): resp_data = {} query = Feedback.query query.count() # 这个就是取得总的页数 req = request.values lib_location = app.config['LIB_LOCATION'] page = int(req['p']) if ('p' in req and req['p']) else 1 if 'status' in req and int(req['status']) > -1: query = query.filter(Feedback.status == int(req['status'])) if 'location' in req and int(req['location']) > -1: query = query.filter(Feedback.location == lib_location[req['location']]) page_params = { 'total': query.count(), 'page_size': app.config['PAGE_SIZE'], 'page': page, 'display': app.config['PAGE_DISPLAY'], 'url': request.full_path.replace("&p={}".format(page), "") } pages = iPagination(page_params) offset = (page - 1) * app.config['PAGE_SIZE'] limit = app.config['PAGE_SIZE'] * page list = query.order_by(Feedback.id.asc()).all()[offset:limit] resp_data['list'] = list resp_data['pages'] = pages resp_data['search_con'] = req resp_data['status_mapping'] = app.config['STATUS_MAPPING'] resp_data['lib_location'] = app.config['LIB_LOCATION'] resp_data['current'] = 'feedback' return ops_render("feedback/feedback.html", resp_data)