return catalog materials when cat data is fetched

This commit is contained in:
Seth Ladygo
2019-05-14 16:05:55 -07:00
parent 3990774de3
commit 9d18b47aee
3 changed files with 55 additions and 71 deletions

View File

@ -33,7 +33,11 @@ def catalogedit(request, id=0):
@login_required
def get_catalog(request, id):
cat = get_object_or_404(Catalog, Q(id=id) & (Q(owner=request.user) | Q(public=True)))
return JsonResponse(cat.data, safe=False)
prods = cat.products()
return JsonResponse({
'catalog': cat.data,
'products': [p.serialize() for p in prods],
})
@csrf_exempt