fix
This commit is contained in:
parent
7e1fec5bb4
commit
25cc63fe08
24
main.ipynb
24
main.ipynb
@ -1614,7 +1614,29 @@
|
|||||||
"):\n",
|
"):\n",
|
||||||
" exhibition = await exhibition_collection.find_one({'_id': ObjectId(exhibition_id)})\n",
|
" exhibition = await exhibition_collection.find_one({'_id': ObjectId(exhibition_id)})\n",
|
||||||
" if exhibition:\n",
|
" if exhibition:\n",
|
||||||
" posts = await delivery_collection.find({'status': 'На выставке', \"exhibition_id\": exhibition_id}).to_list()\n",
|
" match_ = {\n",
|
||||||
|
" \"$or\": [\n",
|
||||||
|
" {\"sender._id\": user.get('_id')},\n",
|
||||||
|
" {\"user._id\": user.get('_id')},\n",
|
||||||
|
" {\"receiver._id\": user.get('_id')}\n",
|
||||||
|
" ],\n",
|
||||||
|
" 'prod': PROD,\n",
|
||||||
|
" }\n",
|
||||||
|
" if data.get('competition'):\n",
|
||||||
|
" match_.update({'competition_id': data.get('competition').get('_id')})\n",
|
||||||
|
" if data.get('exhibition_id'):\n",
|
||||||
|
" match_.update({'exhibition_id': data.get('exhibition_id')})\n",
|
||||||
|
" cursor = delivery_collection.aggregate([\n",
|
||||||
|
" {\"$match\": match_},\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",
|
||||||
|
" posts = [doc async for doc in cursor if doc.get('status') == 'На выставке']\n",
|
||||||
" return templates.TemplateResponse(\n",
|
" return templates.TemplateResponse(\n",
|
||||||
" request=request, name=\"exhibition/index.html\", context={\"id\": 1, \"user\": user, \"exhibition\": exhibition, \"posts\": posts}\n",
|
" request=request, name=\"exhibition/index.html\", context={\"id\": 1, \"user\": user, \"exhibition\": exhibition, \"posts\": posts}\n",
|
||||||
" )\n",
|
" )\n",
|
||||||
|
|||||||
24
main.py
24
main.py
@ -1201,7 +1201,29 @@ async def exhibition_members(
|
|||||||
):
|
):
|
||||||
exhibition = await exhibition_collection.find_one({'_id': ObjectId(exhibition_id)})
|
exhibition = await exhibition_collection.find_one({'_id': ObjectId(exhibition_id)})
|
||||||
if exhibition:
|
if exhibition:
|
||||||
posts = await delivery_collection.find({'status': 'На выставке', "exhibition_id": exhibition_id}).to_list()
|
match_ = {
|
||||||
|
"$or": [
|
||||||
|
{"sender._id": user.get('_id')},
|
||||||
|
{"user._id": user.get('_id')},
|
||||||
|
{"receiver._id": user.get('_id')}
|
||||||
|
],
|
||||||
|
'prod': PROD,
|
||||||
|
}
|
||||||
|
if data.get('competition'):
|
||||||
|
match_.update({'competition_id': data.get('competition').get('_id')})
|
||||||
|
if data.get('exhibition_id'):
|
||||||
|
match_.update({'exhibition_id': data.get('exhibition_id')})
|
||||||
|
cursor = delivery_collection.aggregate([
|
||||||
|
{"$match": match_},
|
||||||
|
{"$sort": {"_id": -1}},
|
||||||
|
{"$group": {
|
||||||
|
"_id": "$post_id",
|
||||||
|
"doc": {"$first": "$$ROOT"}
|
||||||
|
}},
|
||||||
|
{"$replaceRoot": {"newRoot": "$doc"}},
|
||||||
|
{"$sort": {"_id": -1}},
|
||||||
|
])
|
||||||
|
posts = [doc async for doc in cursor if doc.get('status') == 'На выставке']
|
||||||
return templates.TemplateResponse(
|
return templates.TemplateResponse(
|
||||||
request=request, name="exhibition/index.html", context={"id": 1, "user": user, "exhibition": exhibition, "posts": posts}
|
request=request, name="exhibition/index.html", context={"id": 1, "user": user, "exhibition": exhibition, "posts": posts}
|
||||||
)
|
)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user