diff --git a/app/blueprints/api/collections/routes.py b/app/blueprints/api/collections/routes.py index bb8253c..39c83a9 100644 --- a/app/blueprints/api/collections/routes.py +++ b/app/blueprints/api/collections/routes.py @@ -1,3 +1,21 @@ from flask import Blueprint, render_template, request +from app.models.collection import Collection +from app.extensions import db + collections = Blueprint("collections", __name__, url_prefix="/collections", template_folder="templates") + +@collections.route("/", 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 "Здесь ничего нет", 200 + + return "", 204 \ No newline at end of file diff --git a/app/blueprints/api/collections/templates/collections/card.j2 b/app/blueprints/api/collections/templates/collections/card.j2 index da0f3a7..9fcd973 100644 --- a/app/blueprints/api/collections/templates/collections/card.j2 +++ b/app/blueprints/api/collections/templates/collections/card.j2 @@ -1,19 +1,18 @@
-
{{ collection.name }}
-
-
    -
  • {{ collection.users.lenght() }}
  • -
-
- +
{{ collection.name }}
+
    +
  • Кол-во пользрвателей: {{ collection.users|length }}
  • +
+
\ No newline at end of file diff --git a/app/blueprints/api/collections/templates/collections/grid.j2 b/app/blueprints/api/collections/templates/collections/grid.j2 index be01f3e..b15f23c 100644 --- a/app/blueprints/api/collections/templates/collections/grid.j2 +++ b/app/blueprints/api/collections/templates/collections/grid.j2 @@ -1,7 +1,9 @@ +
{% for collection in collections %} -
+
{% include "collections/card.j2" %}
{% else %} - Здесь ничего нет -{% endfor %} \ No newline at end of file + Здесь ничего нет. +{% endfor %} +
\ No newline at end of file