Unify document type selection forms

Merge all document type selection forms into a single smarter form
that can perform permission filtering and allow single or multiple
selections.

This commit also add the document type selection for submit
view to the file metadata app.

This commit also updates the document type selection views
for the OCR, document parsing, and upload wizard to use
the new document type selection form and removes their
respective document type selection forms.

Signed-off-by: Roberto Rosario <Roberto.Rosario@mayan-edms.com>
This commit is contained in:
Roberto Rosario
2018-12-14 18:06:23 -04:00
parent 315e70309b
commit 4d46ca3343
16 changed files with 279 additions and 145 deletions

View File

@@ -7,12 +7,9 @@ from django.utils.safestring import mark_safe
from django.utils.translation import ugettext
from django.utils.translation import ugettext_lazy as _
from mayan.apps.acls.models import AccessControlList
from mayan.apps.common.widgets import TextAreaDiv
from mayan.apps.documents.models import DocumentType
from .models import DocumentPageContent
from .permissions import permission_parse_document
class DocumentContentForm(forms.Form):
@@ -83,18 +80,3 @@ class DocumentPageContentForm(forms.Form):
content = conditional_escape(force_text(page_content))
self.fields['contents'].initial = mark_safe(content)
class DocumentTypeSelectForm(forms.Form):
document_type = forms.ModelChoiceField(
queryset=DocumentType.objects.none(), label=('Document type')
)
def __init__(self, *args, **kwargs):
user = kwargs.pop('user')
super(DocumentTypeSelectForm, self).__init__(*args, **kwargs)
queryset = AccessControlList.objects.filter_by_access(
permission=permission_parse_document,
queryset=DocumentType.objects.all(), user=user,
)
self.fields['document_type'].queryset = queryset