Allow unsafe async and make more things async

This commit is contained in:
2022-10-12 07:22:22 +01:00
parent 5bf65e3c90
commit 22df27178b
8 changed files with 215 additions and 25 deletions

View File

@@ -1,12 +1,14 @@
from asgiref.sync import sync_to_async
from core.models import Plan
def assemble_plan_map(product_id_filter=None):
async def assemble_plan_map(product_id_filter=None):
"""
Get all the plans from the database and create an object Stripe wants.
"""
line_items = []
for plan in Plan.objects.all():
for plan in await sync_to_async(list)(Plan.objects.all()):
if product_id_filter:
if plan.product_id != product_id_filter:
continue