def door2door(place): page = h.safeint(request.args.get('page', 1), default=1, minvalue=1) total = place.get_door2door_count() limit = 50 pagination = Pagination(total=total, page=page, per_page=limit, bs_version=3, prev_label="« Prev", next_label="Next »") entries = place.get_door2door_entries(limit=limit, offset=(page - 1) * limit) return render_template("door2door.html", place=place, entries=entries, pagination=pagination)
def test_safeint(): assert safeint("123") == 123 assert safeint("123x", default=1) == 1 assert safeint("-1", default=1, minvalue=1) == 1 assert safeint("100", default=1, maxvalue=35) == 35