Ejemplo n.º 1
0
def get_lists():
    c = DatabaseConnection()

    listid = request.args.get("listid", 0)
    if listid:
        l = c.get_list(listid)
        if not l:
            return {"err": "list does not exist"}, 409
        return {"list": l}, 200

    username = request.args.get("username", "")
    if not username:
        return {"lists": c.get_lists()}, 200

    user = c.get_user(username=username)
    if not user:
        return {"err": "user does not exist"}, 409

    return {"lists": c.get_lists(userid=user["id"])}, 200