Insert data into all project columns

This commit is contained in:
LoRiot 2022-10-17 14:17:49 +03:00
parent a107f13a24
commit 1f68db20fc
2 changed files with 15 additions and 14 deletions

View file

@ -31,14 +31,13 @@ async def create_project(message: types.Message, state: FSMContext):
)
async def get_project_fields(message: types.Message, repo: Repos, state: FSMContext):
# TODO: для тегов и категорий вытаскивать из таблиц индексы,
# значением для creator должен быть user_id.
async def get_project_fields(
message: types.Message, repo: Repos, state: FSMContext
):
field_patterns = {
"Название проекта": str,
"Описание": str,
"Кол-во участников": int,
"Статус": BitString,
"Название проекта": str, "Описание": str, "Контакты": str,
"Кол-во участников": int, "Статус": BitString, "Теги": str,
"Категория": str
}
field_values = []
@ -51,8 +50,11 @@ async def get_project_fields(message: types.Message, repo: Repos, state: FSMCont
pass
logger.debug(field_values)
await repo.get_repo(ProjectRepo).add(
*field_values, user_id=message.from_user.id
)
await state.reset_state()
await repo.get_repo(ProjectRepo).add(*field_values)
def register_projects_handlers(dp: Dispatcher):

View file

@ -32,14 +32,13 @@ class UserRepo(BaseRepo):
class ProjectRepo(BaseRepo):
async def add(self, name: str, description: str, *args):
async def add(self, *args, user_id: int):
await self.conn.execute(
"INSERT INTO projects "
"(name, description, contributors, status) "
"VALUES ($1, $2, $3, $4)",
name,
description,
*args
"(creator, name, description, contacts, "
"contributors, status, tag, category) "
"VALUES ($1, $2, $3, $4, $5, $6, $7, $8)",
user_id, *args
)
async def get(self, user_id: int):