From de3a5e735ddb6d151ca1bec83c47ecf1bd468e1fe7661c6d0d1f3d4cb3363c8e Mon Sep 17 00:00:00 2001 From: vladislav Date: Tue, 1 Sep 2026 11:23:06 -0400 Subject: [PATCH] fix --- main.ipynb | 7 +++++-- main.py | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/main.ipynb b/main.ipynb index 0bd8dbf..1603022 100644 --- a/main.ipynb +++ b/main.ipynb @@ -3235,9 +3235,12 @@ "@app.put(\"/api/post/{post_id}/sale\", response_model=dict)\n", "async def sale_painting(\n", " post_id: str,\n", - " current_user: Dict = Security(get_current_user, scopes=[\"create:posts\"])\n", + " current_user: Dict = Security(get_current_user)\n", " ):\n", - " await posts_collection.update_one({'_id': ObjectId(post_id), 'user._id': current_user.get('_id')}, {'$set': {\"status\": \"Продано\"}})\n", + " fin = [{'_id': ObjectId(post_id), 'user._id': current_user.get('_id')}]\n", + " if 'partner' in current_user.roles:\n", + " fin.append({'_id': ObjectId(post_id)})\n", + " await posts_collection.update_one({'$or': fin}, {'$set': {\"status\": \"Продано\"}})\n", " return {'ok': True}" ], "display_name": ".venv" diff --git a/main.py b/main.py index 7c3d905..8918231 100644 --- a/main.py +++ b/main.py @@ -2401,9 +2401,12 @@ async def post_painting( @app.put("/api/post/{post_id}/sale", response_model=dict) async def sale_painting( post_id: str, - current_user: Dict = Security(get_current_user, scopes=["create:posts"]) + current_user: Dict = Security(get_current_user) ): - await posts_collection.update_one({'_id': ObjectId(post_id), 'user._id': current_user.get('_id')}, {'$set': {"status": "Продано"}}) + fin = [{'_id': ObjectId(post_id), 'user._id': current_user.get('_id')}] + if 'partner' in current_user.roles: + fin.append({'_id': ObjectId(post_id)}) + await posts_collection.update_one({'$or': fin}, {'$set': {"status": "Продано"}}) return {'ok': True} @app.put("/api/post/{post_id}", response_model=dict)