def get(self): total = UserModel.query.count() current_page = request.args.get('page', 1) pager = Pager(members_per_page, total) pager.set_current_page(current_page) users = (UserModel.query .order_by(UserModel.date_created.desc()) .offset(pager.offset) .limit(pager.limit).all()) return render('members.html', users=users, pager=pager)
def get(self, time_order=False): q = ShowModel.query.filter_by(showable=0) total = q.count() current_page = request.args.get('page', 1) pager = Pager(members_per_page, total) pager.set_current_page(current_page) if time_order: medias =\ (q .order_by(ShowModel.date_tagged.desc()) .order_by(ShowModel.date_created.desc()) .offset(pager.offset) .limit(pager.limit).all()) else: mids = redis.lrange('zhinsta:show:list', pager.offset, pager.offset + pager.limit - 1) medias = [ShowModel.query.get(x) for x in mids] return render('show.html', medias=medias, pager=pager)