From 7706a8b7d97b558063b8a52549474574d1327e4f Mon Sep 17 00:00:00 2001 From: chrisjsimpson Date: Sun, 8 Sep 2024 14:59:53 +0100 Subject: [PATCH] Fix #1404 seed plan price lists during development --- subscribie/__init__.py | 5 +++++ subscribie/models.py | 3 +-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/subscribie/__init__.py b/subscribie/__init__.py index 33da1048..51d8ac64 100644 --- a/subscribie/__init__.py +++ b/subscribie/__init__.py @@ -260,6 +260,11 @@ def initdb(): else: log.info("Database already seeded.") con.close() + # assignDefaultPriceLists to each plan + plans = Plan.query.all() + for plan in plans: + plan.assignDefaultPriceLists() + database.session.commit() @app.cli.command() @click.argument("days", type=int) diff --git a/subscribie/models.py b/subscribie/models.py index 08e14b4a..cb7c6a48 100644 --- a/subscribie/models.py +++ b/subscribie/models.py @@ -722,7 +722,6 @@ def getPrice(self, currency): f"Searching for price_list in currency {currency} for plan {self.title}" # noqa: E501 ) - # Not all plans will have a price_list, if not, return error price_list_found_for_currency = False for price_list in self.price_lists: log.debug(f"only use price list if currency {currency}") @@ -745,7 +744,7 @@ def getPrice(self, currency): ) if price_list_found_for_currency is False: msg = f"Could not find price_list for currency: {currency}. There are {len(self.price_lists)} connected to this plan ({self.uuid}), but none of them are for currency {currency}" # noqa: E501 - log.warning(msg) + log.error(msg) return False, msg log.debug( f"getPrice returning sell price: {sell_price} for plan {self.title}" # noqa: E501