diff --git a/compensation/forms/modalForms.py b/compensation/forms/modalForms.py
index ddf8502b..6436a7c8 100644
--- a/compensation/forms/modalForms.py
+++ b/compensation/forms/modalForms.py
@@ -21,7 +21,7 @@ from konova.contexts import BaseContext
from konova.forms import BaseModalForm, NewDocumentModalForm, RemoveModalForm
from konova.models import DeadlineType
from konova.utils.message_templates import FORM_INVALID, ADDED_COMPENSATION_STATE, ADDED_DEADLINE, \
- ADDED_COMPENSATION_ACTION, PAYMENT_EDITED, COMPENSATION_STATE_EDITED
+ ADDED_COMPENSATION_ACTION, PAYMENT_EDITED, COMPENSATION_STATE_EDITED, COMPENSATION_ACTION_EDITED
class NewPaymentForm(BaseModalForm):
@@ -466,6 +466,33 @@ class NewActionModalForm(BaseModalForm):
return action
+class EditCompensationActionModalForm(NewActionModalForm):
+ action = None
+
+ def __init__(self, *args, **kwargs):
+ self.action = kwargs.pop("action", None)
+ super().__init__(*args, **kwargs)
+ form_data = {
+ "action_type": self.action.action_type,
+ "action_type_details": self.action.action_type_details.all(),
+ "amount": self.action.amount,
+ "unit": self.action.unit,
+ "comment": self.action.comment,
+ }
+ self.load_initial_data(form_data)
+
+ def save(self):
+ action = self.action
+ action.action_type = self.cleaned_data.get("action_type", None)
+ action.action_type_details.set(self.cleaned_data.get("action_type_details", []))
+ action.amount = self.cleaned_data.get("amount", None)
+ action.unit = self.cleaned_data.get("unit", None)
+ action.comment = self.cleaned_data.get("comment", None)
+ action.save()
+ self.instance.mark_as_edited(self.user, self.request, edit_comment=COMPENSATION_ACTION_EDITED)
+ return action
+
+
class NewCompensationDocumentModalForm(NewDocumentModalForm):
document_model = CompensationDocument
diff --git a/ema/templates/ema/detail/includes/actions.html b/ema/templates/ema/detail/includes/actions.html
index 74f0564a..30e5e527 100644
--- a/ema/templates/ema/detail/includes/actions.html
+++ b/ema/templates/ema/detail/includes/actions.html
@@ -58,9 +58,12 @@
{{ action.comment }}
-
+ |
{% if is_default_member and has_access %}
- |