From cf76eb5b90b08cf33a3cfac0da46bf121f834658 Mon Sep 17 00:00:00 2001 From: winet Date: Thu, 7 Mar 2024 02:22:53 +1000 Subject: [PATCH] Added collections routes --- app/blueprints/api/collections/routes.py | 3 +++ .../collections/templates/collections/card.j2 | 19 +++++++++++++++++++ .../collections/templates/collections/grid.j2 | 7 +++++++ app/blueprints/api/routes.py | 4 +++- app/blueprints/frontend/routes.py | 8 +++++++- .../frontend/templates/collections.j2 | 14 ++++++++++++++ 6 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 app/blueprints/api/collections/routes.py create mode 100644 app/blueprints/api/collections/templates/collections/card.j2 create mode 100644 app/blueprints/api/collections/templates/collections/grid.j2 create mode 100644 app/blueprints/frontend/templates/collections.j2 diff --git a/app/blueprints/api/collections/routes.py b/app/blueprints/api/collections/routes.py new file mode 100644 index 0000000..bb8253c --- /dev/null +++ b/app/blueprints/api/collections/routes.py @@ -0,0 +1,3 @@ +from flask import Blueprint, render_template, request + +collections = Blueprint("collections", __name__, url_prefix="/collections", template_folder="templates") diff --git a/app/blueprints/api/collections/templates/collections/card.j2 b/app/blueprints/api/collections/templates/collections/card.j2 new file mode 100644 index 0000000..da0f3a7 --- /dev/null +++ b/app/blueprints/api/collections/templates/collections/card.j2 @@ -0,0 +1,19 @@ +
+
{{ collection.name }}
+
+
    +
  • {{ collection.users.lenght() }}
  • +
+
+ + + +
\ 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 new file mode 100644 index 0000000..be01f3e --- /dev/null +++ b/app/blueprints/api/collections/templates/collections/grid.j2 @@ -0,0 +1,7 @@ +{% for collection in collections %} +
+ {% include "collections/card.j2" %} +
+{% else %} + Здесь ничего нет +{% endfor %} \ No newline at end of file diff --git a/app/blueprints/api/routes.py b/app/blueprints/api/routes.py index 0cd1db4..b4891e1 100644 --- a/app/blueprints/api/routes.py +++ b/app/blueprints/api/routes.py @@ -3,9 +3,11 @@ from flask import Blueprint from .tasks.routes import tasks from .sessions.routes import sessions from .users.routes import users +from .collections.routes import collections api = Blueprint("api", __name__, url_prefix="/api") api.register_blueprint(users) api.register_blueprint(tasks) -api.register_blueprint(sessions) \ No newline at end of file +api.register_blueprint(sessions) +api.register_blueprint(collections) \ No newline at end of file diff --git a/app/blueprints/frontend/routes.py b/app/blueprints/frontend/routes.py index b22e35b..f70ef78 100644 --- a/app/blueprints/frontend/routes.py +++ b/app/blueprints/frontend/routes.py @@ -2,6 +2,7 @@ from flask import Blueprint, render_template from app.blueprints.api.sessions.routes import get_sessions from app.blueprints.api.users.routes import get_users from app.blueprints.api.tasks.routes import get_tasks +from app.models.collection import Collection frontend = Blueprint("frontend", __name__, url_prefix="/", template_folder="templates", static_folder="static", static_url_path="/static/frontend") @@ -20,4 +21,9 @@ def tasks(): @frontend.route("/parse/") def parse(id: int): - return render_template("parse.j2", session_id=id, users_template=get_users(id)) \ No newline at end of file + return render_template("parse.j2", session_id=id, users_template=get_users(id)) + +@frontend.route("/collections") +def collections(): + collections = Collection.query.all() + return render_template("collections.j2", collections=collections) \ No newline at end of file diff --git a/app/blueprints/frontend/templates/collections.j2 b/app/blueprints/frontend/templates/collections.j2 new file mode 100644 index 0000000..6773916 --- /dev/null +++ b/app/blueprints/frontend/templates/collections.j2 @@ -0,0 +1,14 @@ +{% extends "base.j2" %} + +{% block title %} +Базы +{% endblock title %} + +{% block main %} +
+
+

Задачи

+
+
+ {% include "collections/grid.j2" %} +{% endblock main %} \ No newline at end of file