def index(): trip_query = Trip.select() trip_list = [] for t in trip_query: trip_list.append(t.as_dict()) result = jsonify({'data': trip_list}) return result
def trips(id): selected_trips = Trip.select().where(Trip.parent_user_id==id) trip_list = [ t.as_dict() for t in selected_trips ] result = jsonify( { 'data': trip_list } ) return result
def map(query): response = geocoder.forward(query) first = response.geojson()['features'][0] latitude = response.geojson()['features'][0]['center'][0] longitude = response.geojson()['features'][0]['center'][1] truncated_address = textwrap.shorten(first['place_name'], width=60, placeholder="...") trips = Trip.select().order_by(Trip.created_at.desc()) return render_template('map.html', truncated_address=truncated_address, response=response, latitude=latitude, longitude=longitude, first=first, trips=trips)
'parent_user': User.select().first().id + 1 }, { 'trip_name': 'Florida Trip', 'parent_user': User.select().first().id + 2 }] for t in triplist: if Trip.get_or_none(Trip.trip_name == t['trip_name']) == None: Trip.create(trip_name=t['trip_name'], parent_user=t['parent_user']) # Trip Events from models.trip_event import TripEvent from datetime import datetime tripevent_list = [{ 'parent_trip': Trip.select().first().id, 'date_time': datetime(2019, 8, 12), 'location': 'Berlin' }, { 'parent_trip': Trip.select().first().id, 'date_time': datetime(2019, 7, 23), 'location': 'Frankfurt' }, { 'parent_trip': Trip.select().first().id + 1, 'date_time': datetime(2019, 4, 18), 'location': 'California' }, { 'parent_trip': Trip.select().first().id + 2, 'date_time': datetime(2019, 3, 22), 'location': 'Arizona' }, {