modify article API return
This commit is contained in:
parent
c9b7683238
commit
8aa4fa2dce
1 changed files with 17 additions and 3 deletions
|
@ -1338,13 +1338,27 @@ def history_json(request):
|
||||||
opegroups_list.append(opegroup_dict)
|
opegroups_list.append(opegroup_dict)
|
||||||
return JsonResponse({ 'opegroups': opegroups_list })
|
return JsonResponse({ 'opegroups': opegroups_list })
|
||||||
|
|
||||||
|
|
||||||
@teamkfet_required
|
@teamkfet_required
|
||||||
def kpsul_articles_data(request):
|
def kpsul_articles_data(request):
|
||||||
articles = (
|
articles = (
|
||||||
Article.objects
|
Article.objects
|
||||||
.values('id', 'name', 'price', 'stock', 'category_id', 'category__name')
|
.filter(is_sold=True)
|
||||||
.filter(is_sold=True))
|
.select_related('category'))
|
||||||
return JsonResponse({ 'articles': list(articles) })
|
articlelist = []
|
||||||
|
|
||||||
|
for article in articles:
|
||||||
|
articlelist.append({
|
||||||
|
'id': article.id,
|
||||||
|
'name': article.name,
|
||||||
|
'price': article.price,
|
||||||
|
'stock': article.stock,
|
||||||
|
'category': {
|
||||||
|
'id': article.category.id,
|
||||||
|
'name': article.category.name,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return JsonResponse(articlelist, safe=False)
|
||||||
|
|
||||||
@teamkfet_required
|
@teamkfet_required
|
||||||
def history(request):
|
def history(request):
|
||||||
|
|
Loading…
Reference in a new issue