Skip to content

Commit

Permalink
Fix #1404 seed plan price lists during development
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisjsimpson committed Sep 8, 2024
1 parent 3e3b675 commit 7706a8b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 5 additions & 0 deletions subscribie/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions subscribie/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand All @@ -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
Expand Down

0 comments on commit 7706a8b

Please sign in to comment.