Log
* adds modal_generic.html template for generic usage * adds M2M field log to BaseObject * adds show log button to controls.html * adds logging on adding related objects * adds render log table using generic modal * adds tooltip to missing values in detail views * adds/updates translations
This commit is contained in:
+38
-5
@@ -25,6 +25,14 @@ class NewCompensationForm(BaseForm):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
def save(self):
|
||||
with transaction.atomic():
|
||||
user_action = UserActionLogEntry.objects.create(
|
||||
user=self.user,
|
||||
action=UserAction.CREATED
|
||||
)
|
||||
# Save action to log
|
||||
|
||||
|
||||
class NewPaymentForm(BaseModalForm):
|
||||
amount = forms.DecimalField(
|
||||
@@ -62,17 +70,23 @@ class NewPaymentForm(BaseModalForm):
|
||||
|
||||
def save(self):
|
||||
with transaction.atomic():
|
||||
action = UserActionLogEntry.objects.create(
|
||||
created_action = UserActionLogEntry.objects.create(
|
||||
user=self.user,
|
||||
action=UserAction.CREATED,
|
||||
)
|
||||
edited_action = UserActionLogEntry.objects.create(
|
||||
user=self.user,
|
||||
action=UserAction.EDITED,
|
||||
comment=_("Added payment"),
|
||||
)
|
||||
pay = Payment.objects.create(
|
||||
created=action,
|
||||
created=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),
|
||||
intervention=self.intervention,
|
||||
)
|
||||
self.intervention.log.add(edited_action)
|
||||
return pay
|
||||
|
||||
|
||||
@@ -99,6 +113,13 @@ class NewStateModalForm(BaseModalForm):
|
||||
|
||||
def save(self, is_before_state: bool = False):
|
||||
with transaction.atomic():
|
||||
user_action = UserActionLogEntry.objects.create(
|
||||
user=self.user,
|
||||
action=UserAction.EDITED,
|
||||
comment=_("Added state")
|
||||
)
|
||||
self.instance.log.add(user_action)
|
||||
|
||||
state = CompensationState.objects.create(
|
||||
biotope_type=self.cleaned_data["biotope_type"],
|
||||
surface=self.cleaned_data["surface"],
|
||||
@@ -196,7 +217,7 @@ class NewDeadlineModalForm(BaseModalForm):
|
||||
|
||||
def save(self):
|
||||
with transaction.atomic():
|
||||
action = UserActionLogEntry.objects.create(
|
||||
created_action = UserActionLogEntry.objects.create(
|
||||
user=self.user,
|
||||
action=UserAction.CREATED
|
||||
)
|
||||
@@ -204,8 +225,14 @@ class NewDeadlineModalForm(BaseModalForm):
|
||||
type=self.cleaned_data["type"],
|
||||
date=self.cleaned_data["date"],
|
||||
comment=self.cleaned_data["comment"],
|
||||
created=action,
|
||||
created=created_action,
|
||||
)
|
||||
edited_action = UserActionLogEntry.objects.create(
|
||||
user=self.user,
|
||||
action=UserAction.EDITED,
|
||||
comment=_("Added deadline")
|
||||
)
|
||||
self.instance.log.add(edited_action)
|
||||
self.instance.deadlines.add(deadline)
|
||||
return deadline
|
||||
|
||||
@@ -260,7 +287,7 @@ class NewActionModalForm(BaseModalForm):
|
||||
with transaction.atomic():
|
||||
user_action = UserActionLogEntry.objects.create(
|
||||
user=self.user,
|
||||
action=UserAction.CREATED
|
||||
action=UserAction.CREATED,
|
||||
)
|
||||
comp_action = CompensationAction.objects.create(
|
||||
action_type=self.cleaned_data["action_type"],
|
||||
@@ -269,6 +296,12 @@ class NewActionModalForm(BaseModalForm):
|
||||
comment=self.cleaned_data["comment"],
|
||||
created=user_action,
|
||||
)
|
||||
edited_action = UserActionLogEntry.objects.create(
|
||||
user=self.user,
|
||||
action=UserAction.EDITED,
|
||||
comment=_("Added action"),
|
||||
)
|
||||
self.instance.log.add(edited_action)
|
||||
self.instance.actions.add(comp_action)
|
||||
return comp_action
|
||||
|
||||
|
||||
Reference in New Issue
Block a user