Exemplo n.º 1
0
            (lat - Collection.lat) * (lat - Collection.lat) +
            (lng - Collection.long) * (lng - Collection.long)).limit(50).all()
        return render_template('nearby_collections.html',
                               nearby_collections=nearby)
    else:
        return render_template('home.html', login_authorized=False)


@app.route('/personalcollections')
def user_collections():
    user_posts = Post.query.filter_by(
        author_id=session['current_user_id']).all()
    user_collections = []
    for post in user_posts:
        if post.collection_id not in user_collections:
            user_collections.append(post.collection_id)
    final_user_collections = []
    for collection in user_collections:
        place_name = Collection.query.filter_by(id=collection).first()
        if place_name is not None:
            final_user_collections.append(place_name)
    return render_template('personal_collections.html',
                           personal_collections=final_user_collections)


if __name__ == '__main__':
    scheduler = APScheduler()
    scheduler.add_interval_job(func=refresh_access_token, seconds=3500)
    scheduler.start()
    app.run()