def works(): num_per_page = 10 work_type = request.args['type'] if 'type' in request.args else 'all' dynasty_abbr = request.args['dynasty'] if 'dynasty' in request.args else 'all' page = int(request.args['page'] if 'page' in request.args else 1) works = Work.get_works(work_type, dynasty_abbr, page, num_per_page) for work in works: work['Content'] = content_clean(work['Content']) works_num = Work.get_works_num(work_type, dynasty_abbr) # page paras total_page = int(math.ceil(works_num / num_per_page)) pre_page = (page - 1) if page > 1 else 1 if total_page == 0: next_page = 1 elif page < total_page: next_page = page + 1 else: next_page = total_page work_types = Work.get_types() dynasties = Dynasty.get_dynasties() return render_template('work/works.html', works=works, works_num=works_num, work_types=work_types, dynasties=dynasties, page=page, total_page=total_page, pre_page=pre_page, next_page=next_page, work_type=work_type, dynasty_abbr=dynasty_abbr)
def works(): num_per_page = 10 work_type = request.args['type'] if 'type' in request.args else 'all' dynasty_abbr = request.args[ 'dynasty'] if 'dynasty' in request.args else 'all' page = int(request.args['page'] if 'page' in request.args else 1) works = Work.get_works(work_type, dynasty_abbr, page, num_per_page) for work in works: work['Content'] = content_clean(work['Content']) works_num = Work.get_works_num(work_type, dynasty_abbr) # page paras total_page = int(math.ceil(works_num / num_per_page)) pre_page = (page - 1) if page > 1 else 1 if total_page == 0: next_page = 1 elif page < total_page: next_page = page + 1 else: next_page = total_page work_types = Work.get_types() dynasties = Dynasty.get_dynasties() return render_template('work/works.html', works=works, works_num=works_num, work_types=work_types, dynasties=dynasties, page=page, total_page=total_page, pre_page=pre_page, next_page=next_page, work_type=work_type, dynasty_abbr=dynasty_abbr)
def works(): works = Work.get_works() for work in works: work['Content'] = re.sub(r'<([^<]+)>', '', work['Content']) work['Content'] = work['Content'].replace('%', '').replace('/', '') return render_template('works.html', works=works)