From d84fb01ad8b7426f442c859e626d2324aee8b3e8d059fb63438608400317b4d5 Mon Sep 17 00:00:00 2001 From: vladislav Date: Tue, 1 Sep 2026 11:15:50 -0400 Subject: [PATCH] feat --- main.ipynb | 21 ++++++++++-- main.py | 12 +++++-- templates/exhibition/index.html | 42 ++++++++++++++++++++++- templates/profile/partner/exhibition.html | 41 ++++++++++++++++++++++ 4 files changed, 111 insertions(+), 5 deletions(-) diff --git a/main.ipynb b/main.ipynb index 245ac9c..0bd8dbf 100644 --- a/main.ipynb +++ b/main.ipynb @@ -3225,6 +3225,23 @@ ], "display_name": ".venv" }, + { + "cell_type": "code", + "execution_count": null, + "id": "8feec4b3", + "metadata": {}, + "outputs": [], + "source": [ + "@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", + " ):\n", + " await posts_collection.update_one({'_id': ObjectId(post_id), 'user._id': current_user.get('_id')}, {'$set': {\"status\": \"Продано\"}})\n", + " return {'ok': True}" + ], + "display_name": ".venv" + }, { "cell_type": "code", "execution_count": null, @@ -4951,7 +4968,7 @@ " d_posts = await delivery_collection.find({'post_id':{'$in':[str(i.get('_id')) for i in posts]}}).to_list()\n", " for post in posts:\n", " for doc in d_posts:\n", - " if str(post.get('_id')) == doc.get('post_id') and doc.get('receiver') and doc.get('receiver').get('_id') == str(user.get('_id')):\n", + " if str(post.get('_id')) == doc.get('post_id') and post.get('status') != 'Продано' and doc.get('receiver') and doc.get('receiver').get('_id') == str(user.get('_id')):\n", " post.update({'status':doc.get('status'), 'receiver': doc.get('receiver'), 'd_id':doc.get('_id')})\n", " return templates.TemplateResponse(\n", " request=request, name=\"profile/partner/exhibition catalog.html\", context={\"now\": datetime.now(), \"user\": user, \"galerists\": galerists, \"genres\": genres, \"living_places\": living_places, \"exhibition\": exhibition, \"posts\": posts}\n", @@ -4978,7 +4995,7 @@ " d_posts = await delivery_collection.find({'post_id':{'$in':[str(i.get('_id')) for i in posts]}}).to_list()\n", " for post in posts:\n", " for doc in d_posts:\n", - " if str(post.get('_id')) == doc.get('post_id') and doc.get('receiver') and doc.get('receiver').get('_id') == str(user.get('_id')):\n", + " if str(post.get('_id')) == doc.get('post_id') and post.get('status') != 'Продано' and doc.get('receiver') and doc.get('receiver').get('_id') == str(user.get('_id')):\n", " post.update({'status':doc.get('status'), 'receiver': doc.get('receiver'), 'd_id':doc.get('_id')})\n", " return templates.TemplateResponse(\n", " request=request, name=\"profile/partner/exhibition.html\", context={\"now\": datetime.now(), \"user\": user, \"exhibition\": exhibition, \"posts\": posts}\n", diff --git a/main.py b/main.py index 9192fcc..7c3d905 100644 --- a/main.py +++ b/main.py @@ -2398,6 +2398,14 @@ async def post_painting( raise HTTPException(status_code=500, detail=str(e)) +@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"]) + ): + await posts_collection.update_one({'_id': ObjectId(post_id), 'user._id': current_user.get('_id')}, {'$set': {"status": "Продано"}}) + return {'ok': True} + @app.put("/api/post/{post_id}", response_model=dict) async def put_painting( background_tasks: BackgroundTasks, @@ -3805,7 +3813,7 @@ async def profile_partner_exhibitions_catalog( d_posts = await delivery_collection.find({'post_id':{'$in':[str(i.get('_id')) for i in posts]}}).to_list() for post in posts: for doc in d_posts: - if str(post.get('_id')) == doc.get('post_id') and doc.get('receiver') and doc.get('receiver').get('_id') == str(user.get('_id')): + if str(post.get('_id')) == doc.get('post_id') and post.get('status') != 'Продано' and doc.get('receiver') and doc.get('receiver').get('_id') == str(user.get('_id')): post.update({'status':doc.get('status'), 'receiver': doc.get('receiver'), 'd_id':doc.get('_id')}) return templates.TemplateResponse( request=request, name="profile/partner/exhibition catalog.html", context={"now": datetime.now(), "user": user, "galerists": galerists, "genres": genres, "living_places": living_places, "exhibition": exhibition, "posts": posts} @@ -3824,7 +3832,7 @@ async def profile_partner_exhibitions( d_posts = await delivery_collection.find({'post_id':{'$in':[str(i.get('_id')) for i in posts]}}).to_list() for post in posts: for doc in d_posts: - if str(post.get('_id')) == doc.get('post_id') and doc.get('receiver') and doc.get('receiver').get('_id') == str(user.get('_id')): + if str(post.get('_id')) == doc.get('post_id') and post.get('status') != 'Продано' and doc.get('receiver') and doc.get('receiver').get('_id') == str(user.get('_id')): post.update({'status':doc.get('status'), 'receiver': doc.get('receiver'), 'd_id':doc.get('_id')}) return templates.TemplateResponse( request=request, name="profile/partner/exhibition.html", context={"now": datetime.now(), "user": user, "exhibition": exhibition, "posts": posts} diff --git a/templates/exhibition/index.html b/templates/exhibition/index.html index 0b1c5b7..7ea08ad 100644 --- a/templates/exhibition/index.html +++ b/templates/exhibition/index.html @@ -95,6 +95,15 @@

{{post.title}}

+

{{post.city or ''}}

@@ -109,7 +118,38 @@ {% endfor %}
- + {#