diff --git a/main.ipynb b/main.ipynb
index 8ec3546..5a85ded 100644
--- a/main.ipynb
+++ b/main.ipynb
@@ -3842,6 +3842,8 @@
" update_doc[\"status\"] = -1\n",
" if payload.date_finish is not None:\n",
" update_doc[\"date_finish\"] = payload.date_finish\n",
+ " if datetime.now(timezone.utc) + timedelta(hours=3) > payload.datetime_start and datetime.now(timezone.utc) + timedelta(hours=3) < payload.date_finish:\n",
+ " update_doc[\"status\"] = 0\n",
" if payload.address is not None:\n",
" await users_collection.update_one(\n",
" { \"_id\": ObjectId(current_user[\"_id\"]) },\n",
@@ -4155,6 +4157,54 @@
],
"display_name": ".venv"
},
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "30acea7c",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "@app.get(\"/b/{bucket_name}/{file_id}/{new_w}/{quality}/{GaussianBlur_radius}\")\n",
+ "async def get_file_with_config(\n",
+ " bucket_name: str,\n",
+ " file_id: str,\n",
+ " new_w: int,\n",
+ " quality: int,\n",
+ " GaussianBlur_radius: int,\n",
+ "):\n",
+ " res = await stream_gridfs_file(file_id, bucket_name)\n",
+ " if res is None:\n",
+ " raise HTTPException(status_code=404, detail=\"File not found\")\n",
+ "\n",
+ " filename, content_type, file_length, iterator = res\n",
+ "\n",
+ " # Собираем все байты файла\n",
+ " data = b\"\".join([chunk async for chunk in iterator()])\n",
+ "\n",
+ " # Обрабатываем\n",
+ " processed = await build_composite(\n",
+ " data,\n",
+ " new_w=new_w,\n",
+ " quality=quality,\n",
+ " GaussianBlur_radius=GaussianBlur_radius,\n",
+ " )\n",
+ "\n",
+ " headers = {\n",
+ " \"Content-Disposition\": content_disposition_header(filename, inline=True),\n",
+ " \"Cache-Control\": \"public, max-age=3600\",\n",
+ " \"ETag\": f'\"{bucket_name}:{file_id}:{new_w}:{quality}:{GaussianBlur_radius}\"',\n",
+ " \"Vary\": \"Accept-Encoding\",\n",
+ " \"Content-Length\": str(len(processed.getvalue())),\n",
+ " }\n",
+ "\n",
+ " return StreamingResponse(\n",
+ " processed,\n",
+ " media_type=\"image/webp\",\n",
+ " headers=headers,\n",
+ " )"
+ ],
+ "display_name": ".venv"
+ },
{
"cell_type": "code",
"execution_count": null,
@@ -4258,7 +4308,7 @@
" users = [doc async for doc in users_collection.find().sort({'_id':-1})]\n",
" return templates.TemplateResponse(\n",
" request=request, name=\"profile/admin/users.html\", context={\"user\": user,\n",
- " 'users': users \n",
+ " 'users': users\n",
" }\n",
" )"
],
diff --git a/main.py b/main.py
index d1d4273..fd3ab3c 100644
--- a/main.py
+++ b/main.py
@@ -2918,6 +2918,8 @@ async def put_competition(
update_doc["status"] = -1
if payload.date_finish is not None:
update_doc["date_finish"] = payload.date_finish
+ if datetime.now(timezone.utc) + timedelta(hours=3) > payload.datetime_start and datetime.now(timezone.utc) + timedelta(hours=3) < payload.date_finish:
+ update_doc["status"] = 0
if payload.address is not None:
await users_collection.update_one(
{ "_id": ObjectId(current_user["_id"]) },
@@ -3195,6 +3197,45 @@ async def get_avatar(user_id: str):
return StreamingResponse(iterator(), media_type=content_type, headers=headers)
+@app.get("/b/{bucket_name}/{file_id}/{new_w}/{quality}/{GaussianBlur_radius}")
+async def get_file_with_config(
+ bucket_name: str,
+ file_id: str,
+ new_w: int,
+ quality: int,
+ GaussianBlur_radius: int,
+):
+ res = await stream_gridfs_file(file_id, bucket_name)
+ if res is None:
+ raise HTTPException(status_code=404, detail="File not found")
+
+ filename, content_type, file_length, iterator = res
+
+ # Собираем все байты файла
+ data = b"".join([chunk async for chunk in iterator()])
+
+ # Обрабатываем
+ processed = await build_composite(
+ data,
+ new_w=new_w,
+ quality=quality,
+ GaussianBlur_radius=GaussianBlur_radius,
+ )
+
+ headers = {
+ "Content-Disposition": content_disposition_header(filename, inline=True),
+ "Cache-Control": "public, max-age=3600",
+ "ETag": f'"{bucket_name}:{file_id}:{new_w}:{quality}:{GaussianBlur_radius}"',
+ "Vary": "Accept-Encoding",
+ "Content-Length": str(len(processed.getvalue())),
+ }
+
+ return StreamingResponse(
+ processed,
+ media_type="image/webp",
+ headers=headers,
+ )
+
async def unsubscribe_user(
email: str,
token: Optional[str] = None
@@ -3275,7 +3316,7 @@ async def profile_admin_statistics(
users = [doc async for doc in users_collection.find().sort({'_id':-1})]
return templates.TemplateResponse(
request=request, name="profile/admin/users.html", context={"user": user,
- 'users': users
+ 'users': users
}
)
diff --git a/templates/competition/form.html b/templates/competition/form.html
index e299948..93ee67a 100644
--- a/templates/competition/form.html
+++ b/templates/competition/form.html
@@ -214,7 +214,8 @@
-
{% endif %}
-
-
-
{% endif %}
-
-
-
-
-
-
-
-
-
-
-
{{ footer.section(user) }}
{% endblock %}
@@ -150,6 +129,42 @@ function normalizeText(str) {
{{ header.style() }}
{{ profile_nav.style() }}
{{ footer.style() }}
+