(db: ...) is place in another place
This commit is contained in:
parent
f25ac9aa0d
commit
9a9ade6145
15
back/api.py
15
back/api.py
@ -41,9 +41,9 @@ app.mount("/uploads", StaticFiles(directory = "./uploads"))
|
|||||||
# add_poems_to_db(database)
|
# add_poems_to_db(database)
|
||||||
|
|
||||||
|
|
||||||
@app.get("/api/announcements", response_model=List[schemas.Announcement], db: Annotated[Session, Depends(utils.get_db)])#адрес объявлений
|
@app.get("/api/announcements", response_model=List[schemas.Announcement])#адрес объявлений
|
||||||
def announcements_list(obsolete: Union[bool, None] = False, user_id: Union[int, None] = None, metro: Union[str, None] = None,
|
def announcements_list(db: Annotated[Session, Depends(utils.get_db)], obsolete: Union[bool, None] = False, user_id: Union[int, None] = None,
|
||||||
category: Union[str, None] = None):
|
metro: Union[str, None] = None,category: Union[str, None] = None):
|
||||||
# параметры для сортировки (схема pydantic schemas.SortAnnouncements)
|
# параметры для сортировки (схема pydantic schemas.SortAnnouncements)
|
||||||
params_to_sort = schemas.SortAnnouncements(obsolete=obsolete, user_id=user_id, metro=metro, category=category)
|
params_to_sort = schemas.SortAnnouncements(obsolete=obsolete, user_id=user_id, metro=metro, category=category)
|
||||||
# получаем результат
|
# получаем результат
|
||||||
@ -72,7 +72,7 @@ def single_announcement(ann_id:int, db: Annotated[Session, Depends(utils.get_db)
|
|||||||
def put_in_db(name: Annotated[str, Form()], category: Annotated[str, Form()], bestBy: Annotated[datetime.date, Form()],
|
def put_in_db(name: Annotated[str, Form()], category: Annotated[str, Form()], bestBy: Annotated[datetime.date, Form()],
|
||||||
address: Annotated[str, Form()], longtitude: Annotated[float, Form()], latitude: Annotated[float, Form()],
|
address: Annotated[str, Form()], longtitude: Annotated[float, Form()], latitude: Annotated[float, Form()],
|
||||||
description: Annotated[str, Form()], metro: Annotated[str, Form()], current_user: Annotated[schemas.User, Depends(utils.get_current_active_user)],
|
description: Annotated[str, Form()], metro: Annotated[str, Form()], current_user: Annotated[schemas.User, Depends(utils.get_current_active_user)],
|
||||||
src: Union[UploadFile, None] = None, trashId: Annotated[int, Form()] = None, db: Annotated[Session, Depends(utils.get_db)]):
|
db: Annotated[Session, Depends(utils.get_db)], src: Union[UploadFile, None] = None, trashId: Annotated[int, Form()] = None):
|
||||||
try:
|
try:
|
||||||
uploaded_name = ""
|
uploaded_name = ""
|
||||||
if src:
|
if src:
|
||||||
@ -132,8 +132,8 @@ def change_book_status(data: schemas.Book, current_user: Annotated[schemas.User,
|
|||||||
|
|
||||||
# reginstration
|
# reginstration
|
||||||
@app.post("/api/signup")
|
@app.post("/api/signup")
|
||||||
def create_user(nickname: Annotated[str, Form()], password: Annotated[str, Form()], name: Annotated[str, Form()]=None,
|
def create_user(nickname: Annotated[str, Form()], password: Annotated[str, Form()], db: Annotated[Session, Depends(utils.get_db)],
|
||||||
surname: Annotated[str, Form()]=None, avatar: Annotated[UploadFile, Form()]=None, db: Annotated[Session, Depends(utils.get_db)]):
|
name: Annotated[str, Form()]=None, surname: Annotated[str, Form()]=None, avatar: Annotated[UploadFile, Form()]=None):
|
||||||
|
|
||||||
if db.query(models.User).filter(models.User.nickname == nickname).first() == None:
|
if db.query(models.User).filter(models.User.nickname == nickname).first() == None:
|
||||||
new_user = models.User(nickname=nickname, hashed_password=utils.get_password_hash(password),
|
new_user = models.User(nickname=nickname, hashed_password=utils.get_password_hash(password),
|
||||||
@ -218,8 +218,7 @@ def get_trashboxes(data: schemas.TrashboxRequest):#крутая функция
|
|||||||
|
|
||||||
|
|
||||||
list_of_category = [] # лист по которому будет отбираться uniq_trashboxes
|
list_of_category = [] # лист по которому будет отбираться uniq_trashboxes
|
||||||
match category:
|
match data.Category:
|
||||||
|
|
||||||
case "PORRIDGE":
|
case "PORRIDGE":
|
||||||
list_of_category=["Опасные отходы", "Иное"]
|
list_of_category=["Опасные отходы", "Иное"]
|
||||||
case "Конспекты":
|
case "Конспекты":
|
||||||
|
Loading…
x
Reference in New Issue
Block a user