Ejemplo n.º 1
0
def share(type_=None):
    search = request.args.get('search')
    client = session['client']
    user = helper.get_or_add_user(client)
    helper.update_files(client, user=user)

    if type_:
        if type_ in helper.TYPE_GETTER:
            files = helper.TYPE_GETTER[type_]()
        else:
            return redirect(url_for('share'))
    else:
        files = helper.get_public_files()

    if search:
        def filter_fn( file_ ):
            return ( not type_ or type_ == file_['type'] ) and ( not search or search.lower() in file_['path'].lower() )
        files = filter(filter_fn, files)
    return render_template('share.html', files=files)
Ejemplo n.º 2
0
def get_folder_data():
    client = session['client']
    user = helper.get_or_add_user(client)
    has_update = helper.update_files(client, user=user)
    folder_obj = db.folder_datas.find_one({'uid' : user['uid']})
    if has_update or not folder_obj:
        folder_data = helper.get_nested_folder(client)
        if not folder_obj:
            db.folder_datas.insert({'uid' : user['uid'],
                                    'data' : folder_data })
        else:
            db.folder_datas.update({'uid' : user['uid']},
                                   {'$set' : {'data' : folder_data }})
    else:
        folder_data = folder_obj['data']
    return jsonify(folder_data)