From 84871d5a7c8771e60b825dca829c629c0c8a8cbc Mon Sep 17 00:00:00 2001 From: Mark Veidemanis Date: Tue, 18 Apr 2023 10:02:29 +0100 Subject: [PATCH] Additional error handling around currencies without rates --- core/clients/platform.py | 6 ++++-- core/lib/money.py | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/core/clients/platform.py b/core/clients/platform.py index e226340..a6f5b7a 100644 --- a/core/clients/platform.py +++ b/core/clients/platform.py @@ -583,8 +583,10 @@ class LocalPlatformClient(ABC): if payment_details: form["account_info"] = payment_details_text form["msg"] = ad_text - form["min_amount"] = round(min_amount, 2) - form["max_amount"] = round(max_amount, 2) + if min_amount is not None: + form["min_amount"] = round(min_amount, 2) + if max_amount is not None: + form["max_amount"] = round(max_amount, 2) if edit: ad_response = await self.api.ad(ad_id=ad_id, **form) diff --git a/core/lib/money.py b/core/lib/money.py index 0011eb0..efb144e 100644 --- a/core/lib/money.py +++ b/core/lib/money.py @@ -138,7 +138,7 @@ class Money(object): rates = await self.get_rates_all() if currency not in rates and not currency == "USD": log.error(f"Can't create ad without rates: {currency}") - return + return (None, None) if currency == "USD": min_amount = min_usd max_amount = max_usd