From 9e82178c66fad8ea010181223e5fe0916bed5428 Mon Sep 17 00:00:00 2001 From: Kseninia Mikhaylova Date: Tue, 19 Nov 2024 13:45:21 +0300 Subject: [PATCH] statuse --- app/main.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/app/main.py b/app/main.py index fabab44..16b3246 100644 --- a/app/main.py +++ b/app/main.py @@ -25,17 +25,21 @@ def format_datetime(value, format="%d %B %Y, %H:%M:%S"): date = datetime.fromisoformat(value) return date.strftime(format) -statuses = [] -def get_statuses(): - get_status_hook = f"{WEBHOOK}/crm.status.list" - status_data = requests.get(get_status_hook) - status_data_json = status_data.json() - global statuses - statuses = status_data_json["result"] - + +statuses = { + "1": "STATE_NEW", + "2": "STATE_PENDING", + "3": "STATE_IN_PROGRESS", + "4": "STATE_SUPPOSEDLY_COMPLETED", + "5": "STATE_COMPLETED", + "6": "STATE_DEFERRED", + "7": "STATE_DECLINED", +} + + # Создаем кастомный фильтр для форматирования дат def format_status(value): - res = [r["NAME"] for r in statuses if r["ID"] == value] + res = statuses[str(value)] if hasattr(statuses, str(value)) else value return res[0] if len(res) else value