Enregistrement des opérations dans K-Psul
- Ajout d'une transaction pour tous les save lors d'une commande K-Psul afin de préserver la cohérence de la BDD
This commit is contained in:
parent
4cb89aa005
commit
e978209ebc
1 changed files with 12 additions and 8 deletions
|
@ -450,14 +450,18 @@ def kpsul_perform_operations(request):
|
|||
|
||||
# Filling cof status for statistics
|
||||
operationgroup.is_cof = operationgroup.on_acc.is_cof
|
||||
# Saving operation group
|
||||
operationgroup.save()
|
||||
data['operationgroup'] = operationgroup.pk
|
||||
|
||||
# Filling operationgroup id for each operations and saving
|
||||
for operation in operations:
|
||||
operation.group = operationgroup
|
||||
operation.save()
|
||||
data['operations'].append(operation.pk)
|
||||
# Apply all saves in a transaction to ensure database integrity
|
||||
try:
|
||||
with transaction.atomic:
|
||||
# Saving operation group
|
||||
operationgroup.save()
|
||||
data['operationgroup'] = operationgroup.pk
|
||||
|
||||
# Filling operationgroup id for each operations and saving
|
||||
for operation in operations:
|
||||
operation.group = operationgroup
|
||||
operation.save()
|
||||
data['operations'].append(operation.pk)
|
||||
|
||||
return JsonResponse(data)
|
||||
|
|
Loading…
Reference in a new issue