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)