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