This commit is contained in:
vladislav 2026-08-17 12:21:34 -04:00
parent 590377afe9
commit 2ecdeadf4a
Signed by: Vladislav
GPG Key ID: D97C9E5E4860EE45
2 changed files with 74 additions and 0 deletions

View File

@ -4584,6 +4584,46 @@
], ],
"display_name": ".venv" "display_name": ".venv"
}, },
{
"cell_type": "code",
"execution_count": null,
"id": "d68edb20",
"metadata": {},
"outputs": [],
"source": [
"@app.get('/profile/delivery/exhibition/{exhibition_id}')\n",
"async def profile_delivery_by_exhibition(request: Request, exhibition_id:str, user: Dict = Security(get_current_user)):\n",
" cursor = delivery_collection.aggregate([\n",
" {\"$match\": {\n",
" \"$or\": [\n",
" {\"sender._id\": user.get('_id')},\n",
" {\"user._id\": user.get('_id')},\n",
" {\"receiver._id\": user.get('_id')}\n",
" ],\n",
" 'exhibition_id': ObjectId(exhibition_id),\n",
" 'prod': PROD,\n",
" }},\n",
" {\"$sort\": {\"_id\": -1}},\n",
" {\"$group\": {\n",
" \"_id\": \"$post_id\",\n",
" \"doc\": {\"$first\": \"$$ROOT\"}\n",
" }},\n",
" {\"$replaceRoot\": {\"newRoot\": \"$doc\"}},\n",
" {\"$sort\": {\"_id\": -1}},\n",
" ])\n",
"\n",
" data = [doc async for doc in cursor]\n",
" return templates.TemplateResponse(\n",
" request=request,\n",
" name=\"profile/delivery_old.html\",\n",
" context={\n",
" \"user\": user,\n",
" \"data\": data,\n",
" }\n",
" )\n"
],
"display_name": ".venv"
},
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
@ -4650,6 +4690,7 @@
" \"exhibitions\": exhibitions,\n", " \"exhibitions\": exhibitions,\n",
" \"competitions\": competitions,\n", " \"competitions\": competitions,\n",
" \"data\": data,\n", " \"data\": data,\n",
" \"now\": datetime.now(),\n",
" \"page_title\": \"Доставка\",\n", " \"page_title\": \"Доставка\",\n",
" \"active_section\": \"delivery\"\n", " \"active_section\": \"delivery\"\n",
" }\n", " }\n",

33
main.py
View File

@ -3487,6 +3487,38 @@ async def profile_delivery_by_competition(request: Request, competition_id:str,
) )
@app.get('/profile/delivery/exhibition/{exhibition_id}')
async def profile_delivery_by_exhibition(request: Request, exhibition_id:str, user: Dict = Security(get_current_user)):
cursor = delivery_collection.aggregate([
{"$match": {
"$or": [
{"sender._id": user.get('_id')},
{"user._id": user.get('_id')},
{"receiver._id": user.get('_id')}
],
'exhibition_id': ObjectId(exhibition_id),
'prod': PROD,
}},
{"$sort": {"_id": -1}},
{"$group": {
"_id": "$post_id",
"doc": {"$first": "$$ROOT"}
}},
{"$replaceRoot": {"newRoot": "$doc"}},
{"$sort": {"_id": -1}},
])
data = [doc async for doc in cursor]
return templates.TemplateResponse(
request=request,
name="profile/delivery_old.html",
context={
"user": user,
"data": data,
}
)
@app.get( @app.get(
"/profile/delivery", "/profile/delivery",
response_class=HTMLResponse, response_class=HTMLResponse,
@ -3546,6 +3578,7 @@ async def profile_delivery(
"exhibitions": exhibitions, "exhibitions": exhibitions,
"competitions": competitions, "competitions": competitions,
"data": data, "data": data,
"now": datetime.now(),
"page_title": "Доставка", "page_title": "Доставка",
"active_section": "delivery" "active_section": "delivery"
} }