Created|Deleted refactoring

* refactors base attributes created and deleted into UserActionLogEntry foreign keys
* refactors all related queries and process logic
* fixes binding_on into binding_date in intervention/detail/view.html
* adds basic __str__ for some models
*
This commit is contained in:
mipel
2021-08-02 11:52:20 +02:00
parent 6bc8ada286
commit 0797a6b99f
17 changed files with 138 additions and 60 deletions
+7 -1
View File
@@ -10,7 +10,9 @@ from django.db import transaction
from django.utils.translation import gettext_lazy as _
from compensation.models import Payment
from konova.enums import UserActionLogEntryEnum
from konova.forms import BaseForm, BaseModalForm
from user.models import UserActionLogEntry
class NewCompensationForm(BaseForm):
@@ -56,8 +58,12 @@ class NewPaymentForm(BaseModalForm):
def save(self):
with transaction.atomic():
action = UserActionLogEntry.objects.create(
user=self.user,
action=UserActionLogEntryEnum.CREATED.value,
)
pay = Payment.objects.create(
created_by=self.user,
created=action,
amount=self.cleaned_data.get("amount", -1),
due_on=self.cleaned_data.get("due", None),
comment=self.cleaned_data.get("transfer_note", None),