#7 New Form
* adds creation of new compensation directly from intervention detail view * adds comment rendering on compensation detail view (WIP) * adds shared_access_required decorator * adds/updates translations
This commit is contained in:
@@ -92,10 +92,21 @@ class NewCompensationForm(BaseForm):
|
||||
)
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
intervention_id = kwargs.pop("intervention_id", None)
|
||||
super().__init__(*args, **kwargs)
|
||||
self.form_title = _("New compensation")
|
||||
self.action_url = reverse("compensation:new")
|
||||
self.cancel_redirect = reverse("compensation:index")
|
||||
|
||||
# If the compensation shall directly be initialized from an intervention, we need to fill in the intervention id
|
||||
# and disable the form field.
|
||||
# Furthermore the action_url needs to be set accordingly.
|
||||
if intervention_id is not None:
|
||||
self.initialize_form_field("intervention", intervention_id)
|
||||
self.disable_form_field("intervention")
|
||||
self.action_url = reverse("compensation:new", args=(intervention_id,))
|
||||
self.cancel_redirect = reverse("intervention:open", args=(intervention_id,))
|
||||
else:
|
||||
self.action_url = reverse("compensation:new")
|
||||
self.cancel_redirect = reverse("compensation:index")
|
||||
|
||||
tmp = Compensation()
|
||||
identifier = tmp._generate_new_identifier()
|
||||
|
||||
Reference in New Issue
Block a user