From 8e4917635185a36153039c4b3f5fd4df4fd43b22 Mon Sep 17 00:00:00 2001 From: phzhik Date: Thu, 7 Dec 2023 07:44:20 +0400 Subject: [PATCH] * Better logs in check_cdek_status() task --- store/tasks.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/store/tasks.py b/store/tasks.py index 5245747..ce219b7 100644 --- a/store/tasks.py +++ b/store/tasks.py @@ -18,6 +18,7 @@ def check_cdek_status(order_id): if not statuses: return + old_status = obj.status new_status = obj.status if CDEKStatus.DELIVERED in statuses: new_status = Checklist.Status.COMPLETED @@ -25,11 +26,12 @@ def check_cdek_status(order_id): new_status = Checklist.Status.CDEK # Update status - if obj.status != new_status: - print(f'Order [{obj.id}] status: {obj.status} -> {new_status}') + if old_status != new_status: + print(f'Order [{obj.id}] status: {old_status} -> {new_status}') obj.status = new_status obj.save() - return new_status + + return f"{old_status} —> {new_status}" @shared_task