bx-2052-deal-tab #2

Merged
ksenia_mikhailova merged 25 commits from bx-2052-deal-tab into main 2024-11-19 13:59:00 +03:00
1 changed files with 13 additions and 9 deletions
Showing only changes of commit 9e82178c66 - Show all commits

View File

@ -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