mirror of
https://gitlab.crans.org/bde/nk20
synced 2025-06-21 09:58:23 +02:00
Add option to add a posteriori a Sogé credit
Signed-off-by: Yohann D'ANELLO <ynerant@crans.org>
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
# Copyright (C) 2018-2021 by BDE ENS Paris-Saclay
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
from django.db import transaction
|
||||
from rest_framework import serializers
|
||||
from note.api.serializers import SpecialTransactionSerializer
|
||||
|
||||
@ -68,6 +68,14 @@ class SogeCreditSerializer(serializers.ModelSerializer):
|
||||
The djangorestframework plugin will analyse the model `SogeCredit` and parse all fields in the API.
|
||||
"""
|
||||
|
||||
@transaction.atomic
|
||||
def save(self, **kwargs):
|
||||
# Update soge transactions after creating a credit
|
||||
instance = super().save(**kwargs)
|
||||
instance.update_transactions()
|
||||
instance.save()
|
||||
return instance
|
||||
|
||||
class Meta:
|
||||
model = SogeCredit
|
||||
fields = '__all__'
|
||||
|
Reference in New Issue
Block a user