Insert data into all project columns
This commit is contained in:
parent
a107f13a24
commit
1f68db20fc
|
@ -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):
|
async def get_project_fields(
|
||||||
# TODO: для тегов и категорий вытаскивать из таблиц индексы,
|
message: types.Message, repo: Repos, state: FSMContext
|
||||||
# значением для creator должен быть user_id.
|
):
|
||||||
field_patterns = {
|
field_patterns = {
|
||||||
"Название проекта": str,
|
"Название проекта": str, "Описание": str, "Контакты": str,
|
||||||
"Описание": str,
|
"Кол-во участников": int, "Статус": BitString, "Теги": str,
|
||||||
"Кол-во участников": int,
|
"Категория": str
|
||||||
"Статус": BitString,
|
|
||||||
}
|
}
|
||||||
field_values = []
|
field_values = []
|
||||||
|
|
||||||
|
@ -51,8 +50,11 @@ async def get_project_fields(message: types.Message, repo: Repos, state: FSMCont
|
||||||
pass
|
pass
|
||||||
|
|
||||||
logger.debug(field_values)
|
logger.debug(field_values)
|
||||||
|
|
||||||
|
await repo.get_repo(ProjectRepo).add(
|
||||||
|
*field_values, user_id=message.from_user.id
|
||||||
|
)
|
||||||
await state.reset_state()
|
await state.reset_state()
|
||||||
await repo.get_repo(ProjectRepo).add(*field_values)
|
|
||||||
|
|
||||||
|
|
||||||
def register_projects_handlers(dp: Dispatcher):
|
def register_projects_handlers(dp: Dispatcher):
|
||||||
|
|
|
@ -32,14 +32,13 @@ class UserRepo(BaseRepo):
|
||||||
|
|
||||||
|
|
||||||
class ProjectRepo(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(
|
await self.conn.execute(
|
||||||
"INSERT INTO projects "
|
"INSERT INTO projects "
|
||||||
"(name, description, contributors, status) "
|
"(creator, name, description, contacts, "
|
||||||
"VALUES ($1, $2, $3, $4)",
|
"contributors, status, tag, category) "
|
||||||
name,
|
"VALUES ($1, $2, $3, $4, $5, $6, $7, $8)",
|
||||||
description,
|
user_id, *args
|
||||||
*args
|
|
||||||
)
|
)
|
||||||
|
|
||||||
async def get(self, user_id: int):
|
async def get(self, user_id: int):
|
||||||
|
|
Reference in a new issue