diff options
| 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 | 
| commit | 660fe3c685da02b05ef7c2e0418e6e9288947914 (patch) | |
| tree | 324ebb63974e24d75980f7c1447c29aa1a1a6333 /ishtar_common/forms_common.py | |
| parent | 53653e8d74e936a89515fbaae77bbbeea578e7f5 (diff) | |
| download | Ishtar-660fe3c685da02b05ef7c2e0418e6e9288947914.tar.bz2 Ishtar-660fe3c685da02b05ef7c2e0418e6e9288947914.zip | |
Documents: redirects - multiple del
Diffstat (limited to 'ishtar_common/forms_common.py')
| -rw-r--r-- | ishtar_common/forms_common.py | 24 | 
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): | 
