statuse
This commit is contained in:
parent
f127435b40
commit
9e82178c66
22
app/main.py
22
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
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue