コード例 #1
0
ファイル: views.py プロジェクト: thenormalsquid/bookend
def dashboard(msg=None):
	user = auth.get_logged_in_user()
	try:
		books = Books.select().where(
			Books.ownership == user).order_by(Books.id.desc())
		return object_list("book_list.html", books, 'book_list')
	except Books.DoesNotExist:
		return render_template("dashboard.html", msg=msg)
	return render_template("dashboard.html", msg=msg)
コード例 #2
0
def del_book(id):
    exists = Books.select().filter(id=id).exists()

    if not exists:
        return jsonify(
            {"message": "Can't find book with id - `{id}`".format(id=id)}), 404

    Books.delete().where(Books.id == id).execute()
    return jsonify({}), 204
コード例 #3
0
ファイル: app.py プロジェクト: MilesHamilton/NYT_API
def endpoint(id=None):
    if request.method == 'GET':
        if id:
            return jsonify(model_to_dict(Books.get(Books.id == id)))
        else:
            bookList = []
            for book in Books.select():
                bookList.append(model_to_dict(book))
            return jsonify(bookList)

    if request.method == 'POST':
        new_book = dict_to_model(Books, request.get_json())
        new_book.save()
        return jsonify({"success": True})
コード例 #4
0
def getlist_book():
    return jsonify(bookSchema.dump(list(Books.select()), many=True).data), 200
コード例 #5
0
ファイル: routings.py プロジェクト: p0cisk/Bookshelf
def api_author_books(aid):
    books_id = set(
        Stories.select(fn.Distinct(
            Stories.book)).where(Stories.author == aid).tuples())
    rs = Books.select().where(Books.id << books_id).dicts()
    return jsonify({'result': list(rs)})