From 71e367322c034fc0fbfedd7ec9ab6453a620dbe8 Mon Sep 17 00:00:00 2001 From: Muhammad Hasan Khan Date: Sun, 6 Sep 2020 23:38:10 -0700 Subject: [PATCH] Remove unverified books from books collection Also removed the unused /hadiths[GET] end point --- main.py | 26 ++------------------------ 1 file changed, 2 insertions(+), 24 deletions(-) diff --git a/main.py b/main.py index d81df25..7970d37 100644 --- a/main.py +++ b/main.py @@ -3,7 +3,6 @@ from sqlalchemy import func, or_ from werkzeug.exceptions import HTTPException - app = Flask(__name__) app.config.from_object("config.Config") @@ -72,14 +71,14 @@ def api_collection(name): @app.route("/v1/collections//books", methods=["GET"]) @paginate_results def api_collection_books(name): - return Book.query.filter_by(collection=name).order_by(func.abs(Book.ourBookID)) + return Book.query.filter_by(collection=name, status=4).order_by(func.abs(Book.ourBookID)) @app.route("/v1/collections//books/", methods=["GET"]) @single_resource def api_collection_book(name, bookNumber): book_id = Book.get_id_from_number(bookNumber) - return Book.query.filter_by(collection=name, ourBookID=book_id) + return Book.query.filter_by(collection=name, status=4, ourBookID=book_id) @app.route("/v1/collections//books//hadiths", methods=["GET"]) @@ -108,27 +107,6 @@ def api_collection_book_chapter(collection_name, bookNumber, chapterId): return Chapter.query.filter_by(collection=collection_name, arabicBookID=book_id, babID=chapterId) -@app.route("/v1/hadiths", methods=["GET"]) -@paginate_results -def api_hadiths(): - collection = request.args.get("collection") - bookNumber = request.args.get("bookNumber") - babId = request.args.get("chapterId") - hadithNumber = request.args.get("hadithNumber") - - queryset = Hadith.query - if hadithNumber: - queryset = queryset.filter_by(hadithNumber=hadithNumber) - if babId: - queryset = queryset.filter_by(babID=float(babId)) - if bookNumber: - queryset = queryset.filter_by(bookNumber=bookNumber) - if collection: - queryset = queryset.filter_by(collection=collection) - - return queryset - - @app.route("/v1/hadiths/", methods=["GET"]) @single_resource def api_hadith(urn):