diff --git a/handlers/projects.py b/handlers/projects.py index 73577fe..61fa7a9 100644 --- a/handlers/projects.py +++ b/handlers/projects.py @@ -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): diff --git a/services/repositories.py b/services/repositories.py index edf4628..6a09d3c 100644 --- a/services/repositories.py +++ b/services/repositories.py @@ -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):