Intervention check
* adds functionality for check button * adds highlighting of important data on detail view for intervention * adds deleting logic to BaseObject model and BaseResource model * adds RunCheckForm * adds check_validity() method to Intervention class * fixes wrong success msg for adding documents * adds/updates translations
This commit is contained in:
@@ -383,3 +383,42 @@ class NewRevocationForm(BaseModalForm):
|
||||
self.instance.legal.revocation = revocation
|
||||
self.instance.legal.save()
|
||||
return revocation
|
||||
|
||||
|
||||
class RunCheckForm(BaseModalForm):
|
||||
checked_intervention = forms.BooleanField(
|
||||
label=_("Checked intervention data"),
|
||||
label_suffix="",
|
||||
widget=forms.CheckboxInput(),
|
||||
required=True,
|
||||
)
|
||||
checked_comps = forms.BooleanField(
|
||||
label=_("Checked compensations data and payments"),
|
||||
label_suffix="",
|
||||
widget=forms.CheckboxInput(),
|
||||
required=True
|
||||
)
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.form_title = _("Run check")
|
||||
self.form_caption = _("I, {} {}, confirm that all necessary control steps have been performed by myself.").format(self.user.first_name, self.user.last_name)
|
||||
|
||||
def is_valid(self):
|
||||
super_result = super().is_valid()
|
||||
# Perform check
|
||||
result, msgs = self.instance.check_validity()
|
||||
self.errors.update(msgs)
|
||||
return result & super_result
|
||||
|
||||
def save(self):
|
||||
with transaction.atomic():
|
||||
user_action = UserActionLogEntry.objects.create(
|
||||
user=self.user,
|
||||
action=UserAction.CHECKED
|
||||
)
|
||||
# Replace old checked
|
||||
if self.instance.checked:
|
||||
self.instance.checked.delete()
|
||||
self.instance.checked = user_action
|
||||
self.instance.save()
|
||||
Reference in New Issue
Block a user