def moderate_view(): if not is_admin(): flask.abort(403) if flask.request.method == 'POST': point_id_list = [ int(p_id) for p_id in flask.request.form.getlist('point_id') ] submit_points_to_osm(point_id_list) text = "%d points uploaded to OSM" % len(point_id_list) return flask.render_template('message.html', text=text) point_dict = lambda p_id, p: { 'id': p_id, 'lat': p['lat'], 'lon': p['lon'], 'marker': marker_for_amenity(p['amenity']), 'name': p['name'], 'type': p['amenity'], } form_data = { 'points': [ point_dict(p_id, p) for p_id, p in database.get_all_points() if p['osm_id'] is None ], } return flask.render_template('moderate.html', **form_data)
def points_for_homepage(): point_data = [] osm_point_ids = set() for p_id, p in database.get_all_points(): point_data.append({ 'lat': p['lat'], 'lon': p['lon'], 'marker': marker_for_amenity(p['amenity']), 'name': p['name'], 'type': p['amenity'], }) if p['osm_id'] is not None: osm_point_ids.add(p['osm_id']) for p in flask.current_app.config['IMPORTED_POINTS']: if p['osm_id'] in osm_point_ids: continue osm_point_ids.add(p['osm_id']) point_data.append({ 'lat': p['lat'], 'lon': p['lon'], 'marker': marker_for_amenity(p['amenity']), 'name': p['name'], 'type': p['amenity'], }) return point_data
def moderate_view(): if not is_admin(): flask.abort(403) if flask.request.method == 'POST': point_id_list = [int(p_id) for p_id in flask.request.form.getlist('point_id')] submit_points_to_osm(point_id_list) text = "%d points uploaded to OSM" % len(point_id_list) return flask.render_template('message.html', text=text) point_dict = lambda p_id, p: { 'id': p_id, 'lat': p['lat'], 'lon': p['lon'], 'marker': marker_for_amenity(p['amenity']), 'name': p['name'], 'type': p['amenity'], } form_data = { 'points': [point_dict(p_id, p) for p_id, p in database.get_all_points() if p['osm_id'] is None], } return flask.render_template('moderate.html', **form_data)
def show_points(): local_points = [] sent_points = [] for p_id, point in database.get_all_points(): point['id'] = p_id if point['osm_id'] is None: local_points.append(point) else: sent_points.append(point) return flask.render_template('points.html', local_points=local_points, sent_points=sent_points)