\ No newline at end of file
diff --git a/app/blueprints/api/collections/templates/collections/collections_section.j2 b/app/blueprints/api/collections/templates/collections/collections_section.j2
new file mode 100644
index 0000000..f6e3494
--- /dev/null
+++ b/app/blueprints/api/collections/templates/collections/collections_section.j2
@@ -0,0 +1,2 @@
+{% include "collections/create_form.j2" %}
+{% include "collections/select.j2" %}
\ No newline at end of file
diff --git a/app/blueprints/api/collections/templates/collections/create_form.j2 b/app/blueprints/api/collections/templates/collections/create_form.j2
new file mode 100644
index 0000000..e45d9e7
--- /dev/null
+++ b/app/blueprints/api/collections/templates/collections/create_form.j2
@@ -0,0 +1,33 @@
+
+
+
+
+ {% if collections_error is defined %}
+
+ {{ collections_error }}
+
+ {% endif %}
+
\ 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 b15f23c..26ea25d 100644
--- a/app/blueprints/api/collections/templates/collections/grid.j2
+++ b/app/blueprints/api/collections/templates/collections/grid.j2
@@ -1,8 +1,6 @@
{% for collection in collections %}
-
- {% include "collections/card.j2" %}
-
+ {% include "collections/card.j2" %}
{% else %}
Здесь ничего нет.
{% endfor %}
diff --git a/app/blueprints/api/collections/templates/collections/select.j2 b/app/blueprints/api/collections/templates/collections/select.j2
new file mode 100644
index 0000000..7fc3d5f
--- /dev/null
+++ b/app/blueprints/api/collections/templates/collections/select.j2
@@ -0,0 +1,7 @@
+
\ No newline at end of file
diff --git a/app/blueprints/api/tasks/routes.py b/app/blueprints/api/tasks/routes.py
index e163b96..30880d8 100644
--- a/app/blueprints/api/tasks/routes.py
+++ b/app/blueprints/api/tasks/routes.py
@@ -16,10 +16,6 @@ def get_tasks():
return render_template("tasks_cards.j2", tasks=tasks, sessions=sessions)
-@tasks.route("/", methods=["GET"])
-def get_task(task_id: int):
- ...
-
@tasks.route("/session/", methods=["POST"])
def create_task(session_id: int):
info = request.form
diff --git a/app/blueprints/frontend/routes.py b/app/blueprints/frontend/routes.py
index f70ef78..56885d7 100644
--- a/app/blueprints/frontend/routes.py
+++ b/app/blueprints/frontend/routes.py
@@ -1,6 +1,5 @@
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
@@ -21,7 +20,8 @@ def tasks():
@frontend.route("/parse/")
def parse(id: int):
- return render_template("parse.j2", session_id=id, users_template=get_users(id))
+ collections = Collection.query.all()
+ return render_template("parse.j2", session_id=id, collections=collections)
@frontend.route("/collections")
def collections():
diff --git a/app/blueprints/frontend/templates/parse.j2 b/app/blueprints/frontend/templates/parse.j2
index 3692f51..4aa9ced 100644
--- a/app/blueprints/frontend/templates/parse.j2
+++ b/app/blueprints/frontend/templates/parse.j2
@@ -5,12 +5,19 @@
{% endblock title %}
{% block main %}
-
diff --git a/app/models/collection.py b/app/models/collection.py
index 077fa99..5d0de43 100644
--- a/app/models/collection.py
+++ b/app/models/collection.py
@@ -9,4 +9,9 @@ class Collection(db.Model):
name: Mapped[str] = mapped_column(unique=True, nullable=False)
tasks: Mapped[List['Task']] = relationship("Task", back_populates="collection")
- users: Mapped[List['User']] = relationship("User", cascade="all, delete-orphan", back_populates="collection")
\ No newline at end of file
+ users: Mapped[List['User']] = relationship("User", cascade="all, delete-orphan", back_populates="collection")
+
+ def exists(name: str):
+ collections = Collection.query.filter_by(name=name).all()
+
+ return len(collections) > 0
\ No newline at end of file
diff --git a/paper/parser.py b/paper/parser.py
index e4261b0..5f3589f 100644
--- a/paper/parser.py
+++ b/paper/parser.py
@@ -1,11 +1,9 @@
import asyncio
-import os
from loguru import logger
from paper.client import PaperClient
from paper.errors import IgnoreException, NeedPasswordException, UserPrivacyException
-from paper.models import Message
class PaperParser:
@@ -17,7 +15,7 @@ class PaperParser:
self.users_to_delete = []
- async def invite_users(self, users, group, task = None):
+ async def invite_users(self, users, group, task):
await self.client.invite_self(group)
group_participants = await self.client.get_participants(group)
@@ -33,7 +31,7 @@ class PaperParser:
await self.client.invite_user(user, group)
- except (UserPrivacyException, IgnoreException) as e:
+ except (UserPrivacyException, IgnoreException):
self.users_to_delete.append(user)
logger.warning("Exception occurred. Skipping user...")
@@ -47,6 +45,8 @@ class PaperParser:
# if dialog.is_user:
# messages = tuple(filter(lambda chat_message: message.text == chat_message.text, await self.client.get_messages(dialog)))
# print(messages)
+ if not task:
+ return
for user in users:
try:
@@ -55,7 +55,7 @@ class PaperParser:
await self.client.send_message(user, message, file)
- except (UserPrivacyException, IgnoreException) as e:
+ except (UserPrivacyException, IgnoreException):
self.users_to_delete.append(user)
logger.warning("Exception occurred. Skipping user...")
@@ -84,4 +84,4 @@ class PaperParser:
return self
async def __aexit__(self, *args, **kwargs):
- await self.client.disconnect()
\ No newline at end of file
+ await self.client.disconnect()