* adds is_valid check for NewDeadlineModalForm to implement #345
pull/346/head
mpeltriaux 1 year ago
parent 9035b07801
commit 9615497a61

@ -65,6 +65,22 @@ class NewDeadlineModalForm(BaseModalForm):
self.form_title = _("New deadline") self.form_title = _("New deadline")
self.form_caption = _("Insert data for the new deadline") self.form_caption = _("Insert data for the new deadline")
def is_valid(self):
valid = super().is_valid()
deadline_type = self.cleaned_data.get("type")
comment = self.cleaned_data.get("comment") or None
other_deadline_without_comment = deadline_type == DeadlineType.OTHER and comment is None
if other_deadline_without_comment:
self.add_error(
"comment",
_("Please explain this 'other' type of deadline.")
)
valid &= False
return valid
def save(self): def save(self):
deadline = self.instance.add_deadline(self) deadline = self.instance.add_deadline(self)
return deadline return deadline

Binary file not shown.

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save