def show_people_of_class_at_page(town_name, size, class_name, page): town = Village(town_name, size) try: population = town.classes[class_name]['total'] except KeyError: return redirect( url_for('show_town', town_name=town.name, size=town.size)) if population < 50: return redirect( url_for('show_people_of_class', town_name=town_name, size=size, class_name=class_name)) elif population >= page * 50: return render_template('some-of-class.html', town=town, class_name=class_name, people=iter_over_people(town, class_name, page), page=page, last_page=(int(population / 50) == page)) else: return redirect( url_for('show_people_of_class_at_page', town_name=town.name, size=town.size, class_name=class_name, page=population // 50))
def show_people_of_class(town_name, size, class_name): town = Village(town_name, size) try: population = town.classes[class_name] except KeyError: return redirect( url_for('show_town', town_name=town.name, size=town.size)) if population['total'] <= 50: return render_template('all-of-class.html', town=Village(town_name, size), class_name=class_name, people=iter_over_people(town, class_name)) else: return redirect( url_for('show_people_of_class_at_page', town_name=town_name, size=size, class_name=class_name, page=0))