def list_user_adventures(): user = request.oauth.user adventures = Adventure.objects(users=user) adventures_dict = [] for adventure in adventures: adventures_dict.append(adventure.to_dict()) return jsonify(adventures=adventures_dict)
def add_adventure(): try: name = request.values.get('name', None) user = request.oauth.user adventure = Adventure( slug=slugify(name), name=name, users=[user] ) adventure.save() return jsonify(adventure.to_mongo()) except TypeError as e: logging.error(e) abort(400) except BadRequest: abort(400) except Exception as e: logging.error(e) abort(500) return
def load_tracker(adventure_slug): adventure = Adventure.objects().get(slug=adventure_slug) delorme = adventure.delorme if delorme is not None: return load_data(delorme.url) return Response(bson.json_util.dumps({'error': 'DeLorme tracker URL is not configured.'}), status=500, mimetype='application/json')
def list_adventures(): adventures = Adventure.objects() adventures_dict = [] for adventure in adventures: adventures_dict.append(adventure.to_dict()) return jsonify(adventures=adventures_dict)