summaryrefslogtreecommitdiff
path: root/ishtar_common/forms.py
diff options
context:
space:
mode:
Diffstat (limited to 'ishtar_common/forms.py')
-rw-r--r--ishtar_common/forms.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/ishtar_common/forms.py b/ishtar_common/forms.py
index 18e32cd76..91e9fb3e9 100644
--- a/ishtar_common/forms.py
+++ b/ishtar_common/forms.py
@@ -436,6 +436,22 @@ class FormSet(CustomForm, BaseFormSet):
form.fields[DELETION_FIELD_NAME].label = ''
form.fields[DELETION_FIELD_NAME].widget = self.delete_widget()
+ def _should_delete_form(self, form):
+ """
+ Returns whether or not the form was marked for deletion.
+ If no data, set deletion to True
+ """
+ if form.cleaned_data.get(DELETION_FIELD_NAME, False):
+ return True
+ if not form.cleaned_data or not [
+ __ for __ in form.cleaned_data
+ if __ != DELETION_FIELD_NAME and
+ form.cleaned_data[__] is not None and
+ form.cleaned_data[__] != '']:
+ form.cleaned_data[DELETION_FIELD_NAME] = True
+ return True
+ return False
+
class FormSetWithDeleteSwitches(FormSet):
delete_widget = widgets.DeleteSwitchWidget