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