--- a/app/app.py +++ b/app/app.py @@ -68,8 +68,7 @@ @app.route('/launch/') def launch(context_guid): - c=client.Context.find(guid=context_guid) - client.launch(c[0]['guid']) + client.launch(context_guid) return redirect(url_for('context_grid')) @app.route('/favorites') @@ -112,9 +111,9 @@ vote = request.args.get('vote', None) if context and vote: context = context[5:] #remove "stars-" from id - c=client.Context.find(guid=context) - c[0]['vote'] = vote - c[0].post() + c = client.Context(context) + c['vote'] = vote == 'true' + c.post() return jsonify(vote=vote) @app.route('/resource/search/') @@ -165,7 +164,7 @@ page = int(request.args.get('page', 1)) offset = _PAGE_SIZE * (page - 1) - result = client.Context.find(full_query) + result = client.Context.find(full_query, reply=['guid', 'title', 'vote']) for i in range(offset, offset + _PAGE_SIZE): try: r.append(result[i])