示例#1
0
def handle_500(err):
    return get_fail_response(500, err.description)
示例#2
0
def handle_auth_error(error):
    return get_fail_response(403, error.error.get("description"))
示例#3
0
def handle_404(err):
    return get_fail_response(404, err.description)
示例#4
0
def get_artist(artist_id):
    artist = Artist.query.get(artist_id)
    return get_success_response(artist.format()) if artist else\
        get_fail_response(404, f"artist with id: {artist_id} not found")
示例#5
0
def get_artists_names_list():
    artists = [{'id': artist.id, 'name': artist.name}
               for artist in Artist.query.order_by(Artist.name).all()]
    return get_success_response(artists) if artists else\
        get_fail_response(404, 'no data found')
示例#6
0
def get_all():
    artists = [artist.format()
               for artist in Artist.query.order_by(Artist.name).all()]
    return get_success_response(artists) if artists else\
        get_fail_response(404, 'no data found')
示例#7
0
def get_roles_list():
    roles = [role.format() for role in Role.query.all()]
    return get_success_response(roles) if roles else get_fail_response("no roles found")