# CompensationAction views refactored
* refactors AbstractCompensationActionViews (new, edit, remove) to inherit from BaseModalFormView * refactors KOM, OEK, EMA views for compensation actions * moves message template strings into message_templates.py
This commit is contained in:
@@ -7,10 +7,12 @@ Created on: 18.08.22
|
||||
"""
|
||||
from dal import autocomplete
|
||||
from django import forms
|
||||
from django.shortcuts import get_object_or_404
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from codelist.models import KonovaCode
|
||||
from codelist.settings import CODELIST_COMPENSATION_ACTION_ID, CODELIST_COMPENSATION_ACTION_DETAIL_ID
|
||||
from compensation.models import CompensationAction
|
||||
from intervention.inputs import CompensationActionTreeCheckboxSelectMultiple
|
||||
from konova.forms.modals import BaseModalForm, RemoveModalForm
|
||||
from konova.utils.message_templates import COMPENSATION_ACTION_EDITED, ADDED_COMPENSATION_ACTION
|
||||
@@ -114,7 +116,8 @@ class EditCompensationActionModalForm(NewCompensationActionModalForm):
|
||||
action = None
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.action = kwargs.pop("action", None)
|
||||
action_id = kwargs.pop("action_id", None)
|
||||
self.action = get_object_or_404(CompensationAction, id=action_id)
|
||||
super().__init__(*args, **kwargs)
|
||||
self.form_title = _("Edit action")
|
||||
form_data = {
|
||||
@@ -147,8 +150,8 @@ class RemoveCompensationActionModalForm(RemoveModalForm):
|
||||
action = None
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
action = kwargs.pop("action", None)
|
||||
self.action = action
|
||||
action_id = kwargs.pop("action_id", None)
|
||||
self.action = get_object_or_404(CompensationAction, id=action_id)
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
def save(self):
|
||||
|
||||
Reference in New Issue
Block a user