Added collections routes
This commit is contained in:
parent
6cd6566a06
commit
cf76eb5b90
|
@ -0,0 +1,3 @@
|
||||||
|
from flask import Blueprint, render_template, request
|
||||||
|
|
||||||
|
collections = Blueprint("collections", __name__, url_prefix="/collections", template_folder="templates")
|
|
@ -0,0 +1,19 @@
|
||||||
|
<div data-collection-id="{{ collection.id }}" class="card">
|
||||||
|
<div class="card-header">{{ collection.name }}</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<ul class="list-group list-group-flush">
|
||||||
|
<li class="list-group-item">{{ collection.users.lenght() }}</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<from action="/api/collection/{{ collection.id }}" method="DELETE" class="card-footer px-2 pt-2">
|
||||||
|
<button
|
||||||
|
type="submit"
|
||||||
|
hx-delete='[data-collection-id="{{ collection.id }}"]'
|
||||||
|
hx-swap="outerHTML"
|
||||||
|
hx-confirm="Вы уверены, что хотите удалить коллекцию?"
|
||||||
|
class="btn btn-outline-danger"
|
||||||
|
>
|
||||||
|
Удалить
|
||||||
|
</button>
|
||||||
|
</from>
|
||||||
|
</div>
|
|
@ -0,0 +1,7 @@
|
||||||
|
{% for collection in collections %}
|
||||||
|
<div id="cards-grid" class="row row-cols-1 row-cols-sm-2 row-cols-md-3 row-cols-lg-4">
|
||||||
|
{% include "collections/card.j2" %}
|
||||||
|
</div>
|
||||||
|
{% else %}
|
||||||
|
Здесь ничего нет
|
||||||
|
{% endfor %}
|
|
@ -3,9 +3,11 @@ from flask import Blueprint
|
||||||
from .tasks.routes import tasks
|
from .tasks.routes import tasks
|
||||||
from .sessions.routes import sessions
|
from .sessions.routes import sessions
|
||||||
from .users.routes import users
|
from .users.routes import users
|
||||||
|
from .collections.routes import collections
|
||||||
|
|
||||||
api = Blueprint("api", __name__, url_prefix="/api")
|
api = Blueprint("api", __name__, url_prefix="/api")
|
||||||
|
|
||||||
api.register_blueprint(users)
|
api.register_blueprint(users)
|
||||||
api.register_blueprint(tasks)
|
api.register_blueprint(tasks)
|
||||||
api.register_blueprint(sessions)
|
api.register_blueprint(sessions)
|
||||||
|
api.register_blueprint(collections)
|
|
@ -2,6 +2,7 @@ from flask import Blueprint, render_template
|
||||||
from app.blueprints.api.sessions.routes import get_sessions
|
from app.blueprints.api.sessions.routes import get_sessions
|
||||||
from app.blueprints.api.users.routes import get_users
|
from app.blueprints.api.users.routes import get_users
|
||||||
from app.blueprints.api.tasks.routes import get_tasks
|
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")
|
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/<int:id>")
|
@frontend.route("/parse/<int:id>")
|
||||||
def parse(id: int):
|
def parse(id: int):
|
||||||
return render_template("parse.j2", session_id=id, users_template=get_users(id))
|
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)
|
|
@ -0,0 +1,14 @@
|
||||||
|
{% extends "base.j2" %}
|
||||||
|
|
||||||
|
{% block title %}
|
||||||
|
Базы
|
||||||
|
{% endblock title %}
|
||||||
|
|
||||||
|
{% block main %}
|
||||||
|
<div class="container">
|
||||||
|
<div class="separator">
|
||||||
|
<h2>Задачи</h2>
|
||||||
|
<hr class="divider">
|
||||||
|
</div>
|
||||||
|
{% include "collections/grid.j2" %}
|
||||||
|
{% endblock main %}
|
Loading…
Reference in New Issue