WIP: Aureplop/kpsul js refactor #501
2 changed files with 18 additions and 18 deletions
|
@ -147,7 +147,7 @@ class History {
|
|||
if (options.to && dateUTCToParis(opegroup.content.at).isAfter(moment(options.to)))
|
||||
return false;
|
||||
|
||||
if (options.transfersonly && opegroup.type === 'opegroup')
|
||||
if (options.transfersonly && opegroup.modelname === 'opegroup')
|
||||
return false;
|
||||
|
||||
if (options.accounts && options.accounts.length &&
|
||||
|
@ -155,7 +155,7 @@ class History {
|
|||
return false;
|
||||
|
||||
if (options.checkouts && options.checkouts.length &&
|
||||
(opegroup.type === 'transfergroup' ||
|
||||
(opegroup.modelname === 'transfergroup' ||
|
||||
options.checkouts.indexOf(opegroup.content.checkout_id) < 0))
|
||||
return false;
|
||||
|
||||
|
@ -173,10 +173,10 @@ class History {
|
|||
'canceled_at': ope.canceled_at,
|
||||
'canceled_by': ope.canceled_by,
|
||||
};
|
||||
if (ope.type === 'ope') {
|
||||
if (ope.modelname === 'ope') {
|
||||
this.update_node('purchase', ope.id, update_data)
|
||||
|| this.update_node('specialope', ope.id, update_data);
|
||||
} else if (ope.type === 'transfer') {
|
||||
} else if (ope.modelname === 'transfer') {
|
||||
this.update_node('transfer', ope.id, update_data);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1052,7 +1052,7 @@ def kpsul_perform_operations(request):
|
|||
websocket_data = {}
|
||||
websocket_data['opegroups'] = [{
|
||||
'add': True,
|
||||
'type': 'opegroup',
|
||||
'modelname': 'opegroup',
|
||||
'content': {
|
||||
'id': operationgroup.pk,
|
||||
'amount': operationgroup.amount,
|
||||
|
@ -1067,7 +1067,7 @@ def kpsul_perform_operations(request):
|
|||
'checkout_id': operationgroup.checkout.pk,
|
||||
},
|
||||
'parent': {
|
||||
'type': 'day',
|
||||
'modelname': 'day',
|
||||
'content': {
|
||||
'id': operationgroup.at.strftime('%Y%m%d'),
|
||||
'date': operationgroup.at
|
||||
|
@ -1092,7 +1092,7 @@ def kpsul_perform_operations(request):
|
|||
}
|
||||
|
||||
if ope.type == Operation.PURCHASE:
|
||||
ope_data['type'] = 'purchase'
|
||||
ope_data['modelname'] = 'purchase'
|
||||
ope_data['content'].update({
|
||||
'article_name': ope.article.name,
|
||||
'article_nb': ope.article_nb,
|
||||
|
@ -1101,7 +1101,7 @@ def kpsul_perform_operations(request):
|
|||
ope.addcost_for and ope.addcost_for.trigramme or None,
|
||||
})
|
||||
else:
|
||||
ope_data['type'] = 'specialope'
|
||||
ope_data['modelname'] = 'specialope'
|
||||
ope_data['content'].update({
|
||||
'type': ope.type,
|
||||
'is_checkout': ope.is_checkout,
|
||||
|
@ -1320,7 +1320,7 @@ def kpsul_cancel_operations(request):
|
|||
for ope in opes:
|
||||
websocket_data['opes'].append({
|
||||
'cancellation': True,
|
||||
'type': 'ope',
|
||||
'modelname': 'ope',
|
||||
'id': ope,
|
||||
'canceled_by': canceled_by,
|
||||
'canceled_at': canceled_at,
|
||||
|
@ -1328,7 +1328,7 @@ def kpsul_cancel_operations(request):
|
|||
for ope in transfers:
|
||||
websocket_data['opes'].append({
|
||||
'cancellation': True,
|
||||
'type': 'transfer',
|
||||
'modelname': 'transfer',
|
||||
'id': ope,
|
||||
'canceled_by': canceled_by,
|
||||
'canceled_at': canceled_at,
|
||||
|
@ -1432,7 +1432,7 @@ def history_json(request):
|
|||
opegroup_list = []
|
||||
for opegroup in opegroups:
|
||||
opegroup_dict = {
|
||||
'type': 'opegroup',
|
||||
'modelname': 'opegroup',
|
||||
'content': {
|
||||
'id': opegroup.id,
|
||||
'amount': opegroup.amount,
|
||||
|
@ -1443,7 +1443,7 @@ def history_json(request):
|
|||
opegroup.on_acc and opegroup.on_acc.trigramme or None,
|
||||
},
|
||||
'parent': {
|
||||
'type': 'day',
|
||||
'modelname': 'day',
|
||||
'content': {
|
||||
'id': opegroup.at.strftime('%Y%m%d'),
|
||||
'date': opegroup.at
|
||||
|
@ -1472,7 +1472,7 @@ def history_json(request):
|
|||
ope.canceled_by and ope.canceled_by.trigramme or None)
|
||||
|
||||
if ope.type == Operation.PURCHASE:
|
||||
ope_dict['type'] = 'purchase'
|
||||
ope_dict['modelname'] = 'purchase'
|
||||
ope_dict['content'].update({
|
||||
'article_name': ope.article.name,
|
||||
'article_nb': ope.article_nb,
|
||||
|
@ -1481,7 +1481,7 @@ def history_json(request):
|
|||
ope.addcost_for and ope.addcost_for.trigramme or None,
|
||||
})
|
||||
else:
|
||||
ope_dict['type'] = 'specialope'
|
||||
ope_dict['modelname'] = 'specialope'
|
||||
ope_dict['content'].update({
|
||||
'type': ope.type,
|
||||
'is_checkout': ope.is_checkout,
|
||||
|
@ -1493,14 +1493,14 @@ def history_json(request):
|
|||
for transfergroup in transfergroups:
|
||||
if transfergroup.filtered_transfers:
|
||||
transfergroup_dict = {
|
||||
'type': 'transfergroup',
|
||||
'modelname': 'transfergroup',
|
||||
'content': {
|
||||
'id': transfergroup.id,
|
||||
'at': transfergroup.at,
|
||||
'comment': transfergroup.comment,
|
||||
},
|
||||
'parent': {
|
||||
'type': 'day',
|
||||
'modelname': 'day',
|
||||
'content': {
|
||||
'id': transfergroup.at.strftime('%Y%m%d'),
|
||||
'date': transfergroup.at
|
||||
|
@ -1517,7 +1517,7 @@ def history_json(request):
|
|||
|
||||
for transfer in transfergroup.filtered_transfers:
|
||||
transfer_dict = {
|
||||
'type': 'transfer',
|
||||
'modelname': 'transfer',
|
||||
'content': {
|
||||
'id': transfer.id,
|
||||
'amount': transfer.amount,
|
||||
|
@ -1706,7 +1706,7 @@ def perform_transfers(request):
|
|||
websocket_data = {}
|
||||
websocket_data['opegroups'] = [{
|
||||
'add': True,
|
||||
'type': 'transfergroup',
|
||||
'modelname': 'transfergroup',
|
||||
'id': transfergroup.pk,
|
||||
'at': transfergroup.at,
|
||||
'comment': transfergroup.comment,
|
||||
|
|
Loading…
Reference in a new issue