def overview_json(): return jsonify(items=[{ 'site': { 'title': site.name, 'href': url_for("facilities.site_show", site_id=site.id) }, 'buildings': [{ 'href': url_for("facilities.building_levels", building_shortname=building.short_name), 'title': building.street+" "+building.number } for building in facilities.sort_buildings(site.buildings)] } for site in Site.q.all()])
def overview_json(): T = SiteTable return jsonify(items=[{ 'site': T.site.value(title=site.name, href=url_for("facilities.site_show", site_id=site.id)), 'buildings': [ T.buildings.single_value(href=url_for( "facilities.building_levels", building_shortname=building.short_name), title=building.street_and_number) for building in facilities.sort_buildings(site.buildings) ] } for site in Site.q.order_by(Site.name).all()])
def test_0010_building_name_sorting(self): before = [ "41A", "41", "41B", "3", "5", "41D", "9", "11", "1", "7", "41C" ] after = [ "1", "3", "5", "7", "9", "11", "41", "41A", "41B", "41C", "41D" ] class fake_dorm(object): def __init__(self, num): self.number = num self.street = "fake street" sorted = sort_buildings([fake_dorm(num) for num in before]) self.assertEqual([d.number for d in sorted], after)
def test_building_name_sorting(fake_dorm, before, after): sorted = sort_buildings([fake_dorm(num) for num in before]) assert [d.number for d in sorted] == after
def site_show(site_id): site = Site.q.get(site_id) buildings_list = facilities.sort_buildings(site.buildings) return render_template('facilities/site_show.html', buildings=buildings_list, page_title=site.name)
def building_query(): return sort_buildings(Building.q.all())
def building_query(): return sort_buildings(Building.q.all())