Exemple #1
0
def get_host():
    host_id = get_request_data(request).get('host_id')
    if not host_id:
        return jsonify({'message':
                        "No host id provided"}), HTTP_400_BAD_REQUEST
    host = Host(uid=host_id)
    # 404 if there is a host with no title in db. No unnamed hosts allowed.
    response = host.to_dict()
    if response is None:
        return jsonify({'message': "No such host in db"}), HTTP_404_NOT_FOUND
    score = Score(host_id, session['user_id'])
    response.update({'score': score.score})
    return jsonify(response)
Exemple #2
0
def get_info():
    """If host_id provided returns that host info elif host_id in session returns your host info else 400"""
    if not session.get('host_id'):
        session['host_id'] = current_user.workplace_uid
    host_id = get_request_data(request).get('host_id') or session.get(
        'host_id')
    if not host_id:
        return jsonify({'message':
                        "No host id provided"}), HTTP_400_BAD_REQUEST
    host = Host(uid=host_id)
    # 404 if there is a host with no title in db. No unnamed hosts allowed.
    response = host.to_dict()
    if response is None:
        return jsonify({'message': "No such host in db"}), HTTP_404_NOT_FOUND
    return jsonify(response)