добавил на страницы загрузок эффект матрицы
This commit is contained in:
70
app.py
70
app.py
@@ -628,33 +628,73 @@ def session_workspace(
|
||||
|
||||
|
||||
@app.post("/admin/session/{session_token}/load-match-data")
|
||||
def load_match_data(session_token: str):
|
||||
def load_match_data(request: Request, session_token: str):
|
||||
session_row = get_match_session_by_token(session_token)
|
||||
if not session_row:
|
||||
if request.headers.get("x-requested-with") == "XMLHttpRequest":
|
||||
return JSONResponse(
|
||||
{
|
||||
"success": False,
|
||||
"error": "Сессия не найдена",
|
||||
"redirect_url": "/admin/matches",
|
||||
},
|
||||
status_code=404,
|
||||
)
|
||||
return RedirectResponse(url="/admin/matches", status_code=303)
|
||||
|
||||
match_id = session_row[1]
|
||||
match_external_id = session_row[8]
|
||||
|
||||
run_parser_game(str(match_external_id))
|
||||
|
||||
# сброс ручного состава и тренеров, чтобы подтянулись свежие данные парсера
|
||||
from db import get_connection
|
||||
|
||||
conn = get_connection()
|
||||
try:
|
||||
with conn.cursor() as cur:
|
||||
cur.execute(
|
||||
"DELETE FROM match_lineup_players WHERE match_id = %s", (match_id,)
|
||||
run_parser_game(str(match_external_id))
|
||||
|
||||
# сброс ручного состава и тренеров, чтобы подтянулись свежие данные парсера
|
||||
from db import get_connection
|
||||
|
||||
conn = get_connection()
|
||||
try:
|
||||
with conn.cursor() as cur:
|
||||
cur.execute(
|
||||
"DELETE FROM match_lineup_players WHERE match_id = %s", (match_id,)
|
||||
)
|
||||
cur.execute("DELETE FROM match_coaches WHERE match_id = %s", (match_id,))
|
||||
conn.commit()
|
||||
finally:
|
||||
conn.close()
|
||||
|
||||
except Exception as e:
|
||||
error_text = str(e) or "Ошибка загрузки данных с сайта"
|
||||
|
||||
if request.headers.get("x-requested-with") == "XMLHttpRequest":
|
||||
return JSONResponse(
|
||||
{
|
||||
"success": False,
|
||||
"error": error_text,
|
||||
"redirect_url": f"/admin/session/{session_token}?tab=game",
|
||||
},
|
||||
status_code=500,
|
||||
)
|
||||
cur.execute("DELETE FROM match_coaches WHERE match_id = %s", (match_id,))
|
||||
conn.commit()
|
||||
finally:
|
||||
conn.close()
|
||||
|
||||
return RedirectResponse(url=f"/admin/session/{session_token}", status_code=303)
|
||||
return RedirectResponse(
|
||||
url=f"/admin/session/{session_token}?tab=game",
|
||||
status_code=303,
|
||||
)
|
||||
|
||||
if request.headers.get("x-requested-with") == "XMLHttpRequest":
|
||||
return JSONResponse(
|
||||
{
|
||||
"success": True,
|
||||
"message": "Данные успешно загружены",
|
||||
"redirect_url": f"/admin/session/{session_token}?tab=game",
|
||||
}
|
||||
)
|
||||
|
||||
return RedirectResponse(
|
||||
url=f"/admin/session/{session_token}?tab=game",
|
||||
status_code=303,
|
||||
)
|
||||
|
||||
|
||||
@app.post("/admin/session/{session_token}/close")
|
||||
def close_session(session_token: str):
|
||||
deactivate_match_session(session_token)
|
||||
|
||||
Reference in New Issue
Block a user