adapt history view

This commit is contained in:
Ludovic Stephan 2017-03-10 22:08:44 -03:00
parent eac6c42041
commit 8eae3cee7f

View file

@ -1301,21 +1301,21 @@ def history_json(request):
# Construction de la réponse
opegroups_list = []
ope_list = []
for opegroup in opegroups:
opegroup_dict = {
'id' : opegroup.id,
'amount' : opegroup.amount,
'at' : opegroup.at,
'checkout_id': opegroup.checkout_id,
'is_cof' : opegroup.is_cof,
'comment' : opegroup.comment,
'opes' : [],
'on_acc__trigramme':
'trigramme':
opegroup.on_acc and opegroup.on_acc.trigramme or None,
'day': {'id': opegroup.at.strftime('%Y%m%d'),
'date': opegroup.at},
}
if request.user.has_perm('kfet.is_team'):
opegroup_dict['valid_by__trigramme'] = (
opegroup_dict['valid_by'] = (
opegroup.valid_by and opegroup.valid_by.trigramme or None)
for ope in opegroup.opes.all():
ope_dict = {
@ -1326,17 +1326,17 @@ def history_json(request):
'is_checkout' : ope.is_checkout,
'addcost_amount': ope.addcost_amount,
'canceled_at' : ope.canceled_at,
'article__name':
'article_name':
ope.article and ope.article.name or None,
'addcost_for__trigramme':
'addcost_for':
ope.addcost_for and ope.addcost_for.trigramme or None,
'opegroup': opegroup_dict,
}
if request.user.has_perm('kfet.is_team'):
ope_dict['canceled_by__trigramme'] = (
ope_dict['canceled_by'] = (
ope.canceled_by and ope.canceled_by.trigramme or None)
opegroup_dict['opes'].append(ope_dict)
opegroups_list.append(opegroup_dict)
return JsonResponse({ 'opegroups': opegroups_list })
ope_list.append(ope_dict)
return JsonResponse(ope_list, safe=False)
@teamkfet_required