summaryrefslogtreecommitdiff
path: root/ishtar_common/forms_common.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2019-09-14 12:43:44 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2019-09-14 12:43:44 +0200
commit5054eeb89a13ab09920b6b70130fccdb2c484e36 (patch)
tree324ebb63974e24d75980f7c1447c29aa1a1a6333 /ishtar_common/forms_common.py
parenta287e2dc11534e8c66f1c6c992e2151648b00e51 (diff)
downloadIshtar-5054eeb89a13ab09920b6b70130fccdb2c484e36.tar.bz2
Ishtar-5054eeb89a13ab09920b6b70130fccdb2c484e36.zip
Documents: redirects - multiple del
Diffstat (limited to 'ishtar_common/forms_common.py')
-rw-r--r--ishtar_common/forms_common.py24
1 files changed, 17 insertions, 7 deletions
diff --git a/ishtar_common/forms_common.py b/ishtar_common/forms_common.py
index d8a4523ab..16c9dd52d 100644
--- a/ishtar_common/forms_common.py
+++ b/ishtar_common/forms_common.py
@@ -45,7 +45,7 @@ from .forms import FinalForm, FormSet, reverse_lazy, name_validator, \
TableSelect, ManageOldType, CustomForm, FieldType, FormHeader, \
FormSetWithDeleteSwitches, BSForm, get_data_from_formset, \
file_size_validator, HistorySelect, CustomFormSearch, QAForm, IshtarForm, \
- MultiSearchForm
+ MultiSearchForm, LockForm
from ishtar_common.utils import is_downloadable, clean_session_cache, \
max_size_help
@@ -1371,7 +1371,7 @@ class DocumentSelect(HistorySelect):
}
-class DocumentFormSelection(CustomFormSearch):
+class DocumentFormSelection(LockForm, CustomFormSearch):
SEARCH_AND_SELECT = True
form_label = _(u"Document search")
associated_models = {'pk': models.Document}
@@ -1386,11 +1386,21 @@ class DocumentFormSelection(CustomFormSearch):
),
validators=[models.valid_id(models.Document)])
- def clean(self):
- cleaned_data = self.cleaned_data
- if 'pk' not in cleaned_data or not cleaned_data['pk']:
- raise forms.ValidationError(_(u"You should select an item."))
- return cleaned_data
+
+class DocumentFormMultiSelection(LockForm, MultiSearchForm):
+ form_label = _(u"Document search")
+ associated_models = {'pks': models.Document}
+ pk_key = 'pks'
+
+ pk = forms.CharField(
+ label="", required=False,
+ widget=widgets.DataTable(
+ reverse_lazy('get-document'), DocumentSelect,
+ models.Document,
+ multiple_select=True,
+ gallery=True
+ ),
+ validators=[models.valid_ids(models.Document)])
class QADocumentFormMulti(QAForm):