PaperParser/app/blueprints/api/collections/routes.py

21 lines
632 B
Python
Raw Normal View History

2024-03-07 02:22:53 +10:00
from flask import Blueprint, render_template, request
2024-03-07 02:56:27 +10:00
from app.models.collection import Collection
from app.extensions import db
2024-03-07 02:22:53 +10:00
collections = Blueprint("collections", __name__, url_prefix="/collections", template_folder="templates")
2024-03-07 02:56:27 +10:00
@collections.route("/<int:id>", methods=["DELETE"])
def delete_collection(id: int):
collection: Collection = Collection.query.get_or_404(id)
length = len(Collection.query.all()) - 1
db.session.delete(collection)
db.session.commit()
if length <= 0:
return "<small class=\"form-text\">Здесь ничего нет</small>", 200
return "", 204