feat
This commit is contained in:
parent
13cfb45c6c
commit
f52844c359
23
main.ipynb
23
main.ipynb
@ -3240,7 +3240,28 @@
|
||||
" fin = [{'_id': ObjectId(post_id), 'user._id': current_user.get('_id')}]\n",
|
||||
" if 'partner' in current_user.get('roles', []):\n",
|
||||
" fin.append({'_id': ObjectId(post_id)})\n",
|
||||
" await posts_collection.update_one({'$or': fin}, {'$set': {\"status\": \"Продано\"}})\n",
|
||||
" doc = await posts_collection.update_one({'$or': fin}, {'$set': {\"status\": \"Продано\"}})\n",
|
||||
" if doc.modified_count: \n",
|
||||
" existing = await delivery_collection.find_one(\n",
|
||||
" {\"post_id\": post_id},\n",
|
||||
" {\"_id\": 0}\n",
|
||||
" )\n",
|
||||
" if existing:\n",
|
||||
" update_data = {\n",
|
||||
" \"status\": \"Продано\",\n",
|
||||
" \"post\": {\"status\": \"Продано\"},\n",
|
||||
" }\n",
|
||||
" notify = await notify_in_profile(NotifyItem(\n",
|
||||
" user_id=str(existing[\"user\"][\"_id\"]),\n",
|
||||
" type_item=\"delivery\",\n",
|
||||
" title=\"Картина продана\",\n",
|
||||
" link=\"/profile/delivery\",\n",
|
||||
" text=f\"{str(existing['post']['title'])}\"\n",
|
||||
" ))\n",
|
||||
"\n",
|
||||
" new_doc = {**existing, **update_data, \"notify\": notify.upserted_id}\n",
|
||||
"\n",
|
||||
" result = await delivery_collection.insert_one(new_doc)\n",
|
||||
" return {'ok': True}"
|
||||
],
|
||||
"display_name": ".venv"
|
||||
|
||||
23
main.py
23
main.py
@ -2406,7 +2406,28 @@ async def sale_painting(
|
||||
fin = [{'_id': ObjectId(post_id), 'user._id': current_user.get('_id')}]
|
||||
if 'partner' in current_user.get('roles', []):
|
||||
fin.append({'_id': ObjectId(post_id)})
|
||||
await posts_collection.update_one({'$or': fin}, {'$set': {"status": "Продано"}})
|
||||
doc = await posts_collection.update_one({'$or': fin}, {'$set': {"status": "Продано"}})
|
||||
if doc.modified_count:
|
||||
existing = await delivery_collection.find_one(
|
||||
{"post_id": post_id},
|
||||
{"_id": 0}
|
||||
)
|
||||
if existing:
|
||||
update_data = {
|
||||
"status": "Продано",
|
||||
"post": {"status": "Продано"},
|
||||
}
|
||||
notify = await notify_in_profile(NotifyItem(
|
||||
user_id=str(existing["user"]["_id"]),
|
||||
type_item="delivery",
|
||||
title="Картина продана",
|
||||
link="/profile/delivery",
|
||||
text=f"{str(existing['post']['title'])}"
|
||||
))
|
||||
|
||||
new_doc = {**existing, **update_data, "notify": notify.upserted_id}
|
||||
|
||||
result = await delivery_collection.insert_one(new_doc)
|
||||
return {'ok': True}
|
||||
|
||||
@app.put("/api/post/{post_id}", response_model=dict)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user