statuse
This commit is contained in:
parent
f127435b40
commit
9e82178c66
20
app/main.py
20
app/main.py
|
@ -25,17 +25,21 @@ def format_datetime(value, format="%d %B %Y, %H:%M:%S"):
|
||||||
date = datetime.fromisoformat(value)
|
date = datetime.fromisoformat(value)
|
||||||
return date.strftime(format)
|
return date.strftime(format)
|
||||||
|
|
||||||
statuses = []
|
|
||||||
def get_statuses():
|
statuses = {
|
||||||
get_status_hook = f"{WEBHOOK}/crm.status.list"
|
"1": "STATE_NEW",
|
||||||
status_data = requests.get(get_status_hook)
|
"2": "STATE_PENDING",
|
||||||
status_data_json = status_data.json()
|
"3": "STATE_IN_PROGRESS",
|
||||||
global statuses
|
"4": "STATE_SUPPOSEDLY_COMPLETED",
|
||||||
statuses = status_data_json["result"]
|
"5": "STATE_COMPLETED",
|
||||||
|
"6": "STATE_DEFERRED",
|
||||||
|
"7": "STATE_DECLINED",
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
# Создаем кастомный фильтр для форматирования дат
|
# Создаем кастомный фильтр для форматирования дат
|
||||||
def format_status(value):
|
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
|
return res[0] if len(res) else value
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue